I just want to make rails without a view.
In my 'routes.rb'
resources :pictures do member do post 'dislike' end end
In my 'PictureController.rb'
this does not work
def dislike @picture = Picture.find(params[:id]) @like = Like.find(:user_id => current_user.id, :picture_id => params[:id]) @like.destroy respond_to do |format| format.html { render :action => :show, :id => params[:id], notice: 'You don\'t like this picture anymore.' } format.json { render json: @picture } end end
and do it
def dislike @picture = Picture.find(params[:id]) @like = Like.find(:user_id => current_user.id, :picture_id => params[:id]) @like.destroy respond_to do |format| format.html { redirect_to @picture, notice: 'You don\'t like this picture anymore.' } format.json { render json: @picture } end end
or even that (but this does not apply to me, I want to get feedback for the user through json and through html)
def dislike @picture = Picture.find(params[:id]) @like = Like.find(:user_id => current_user.id, :picture_id => params[:id]) @like.destroy render :nothing => true end
But I keep getting this error message:
ActionView::MissingTemplate: Missing template pictures/dislike, application/like with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.
How can I tell the rails that this action in the PictureController needs no introduction?
Solved!
I really did not solve the problem of transferring rails, I do not need a view, I just created another controller, put a method in it and said that the routing of the routes corresponds to an unfriendly action with a match call. I can’t say for sure, but I think this is a problem with resources :picture in my routes.rb ...
But anyway, thank you guys! =)
ruby-on-rails rails-routing
Crystian Leão
source share