I have the following in my code:
resources :sessions do
...
member do
put :vote
end
end
and within my controller:
def vote
emoji_symbol = params[:emoji]
vote = Vote.find_or_create_by(voteable_id: @session.id, voteable_type: 'Session', user: current_user)
vote.send(emoji_symbol) ? vote.update(emoji_symbol.to_sym => false) : vote.update(emoji_symbol.to_sym => true)
end
to make it work from my view I have to call the following now:
= link_to vote_backend_session_path(@session.id, emoji: :air), method: :put, ...`
I am wondering if there are any downsides to this approach, since I am more familiar with using the ..._params, form_for permitting specific required values and adding a new nested controller.
So what would be 'best practice' here and what are possible downsides to my approach? Would one ever add params within path in rails? Does it make a difference when I want to reuse my vote for other controllers as well?