0
I’m just starting out on ruby on Rails and I’m having a question I need to make a library, I created and I am listing the books, I created a borrow button in each book unit and then this my problem I want to make this button to be clicked already take to the loan page the book ID, I even managed to do that but when I’m going to save the loan he makes a mistake.
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 so:
Lend button on 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 so:
<%= 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 line 4 error:
3 <div class="form-group">
4 <%= f.hidden_field :livro_id, :value => @livro.id %>
5 </div>
In the mistake you put here, can you get the line number and also put it here for us? Seeing exactly the line from where this error occurs will be much easier to help you
– Peoplee