I'm starting right now in ruby on rails and I'm having a question I need to make a library, I created and I am listing the books, I also created a button to borrow in each book unit and there it is my problem I want to make this button to be clicked already take to the page of loan the ID of the book, this I even managed to do it, but when I save the loan, it is an error.
I created this method:
def load_livro
if params[:livro_id]
@livro = livro.find(params[:livro_id])
else
@livro = livro.new
end
end
And I called him like this:
lend button in app / views / books / index.html.erb:
<td class="col-xs-1"><%= link_to 'Emprestar', "/emprestimo/new/#{emprestimo.id}" %></td>
And on the loan page I used it like this:
<%= f.hidden_field :livro_id, :value => @livro.id %>
In this last line of code the following error occurred:
Undefined local variable or method 'livro' did you mean? livro_url
Code snippet with error line 4:
3 <div class="form-group">
4 <%= f.hidden_field :livro_id, :value => @livro.id %>
5 </div>