Hi. I’m trying to pass params to a new page. In my routes I have:
resources :entries
post '/entries/new => 'entries#create'
get '/entries/new' => 'entries#new'
my buttons are here:
<%= button_to "Add Album Post Create", new_entry_path(album_id: @album.id, user_id: current_user.id, active: true, album_spotify_id: @album.spotify_id), method: :post %>
<%= button_to "Add Album New Form", new_entry_path(album_id: @album.id, user_id: current_user.id, active: true, album_spotify_id: @album.spotify_id), method: :get %>
Even though they are the same, the entry_params in the case of the first post method one are:
#<ActionController::Parameters {"album_id"=>"28", "album_spotify_id"=>"2IrrkgAgfGBo4ADlBNFTDl", "user_id"=>"1", "active"=>"true"} permitted: true>
while in the get method case I’ve gotten either:
*** NameError Exception: undefined local variable or method `entry_params' for #<ActionView::Base:0x0000000000fde8>
when looking in the new.html.erb file (entries/new) or:
#<ActionController::Parameters {} permitted: true>
when looking at the EntriesController new function.
If you need any more information just let me know. I’m really confused as to how the button works perfectly when posting, but the other one does not load the new entry_params.