Ruby on Rails
Monday, February 18, 2013
The first solution that comes in my mind:
class PostsController < ApplicationController
before_filter :authenticate_user!, only: [:create, :update, :destroy]
def authenticate_user!
session[:post] = params[:post] unless user_signed_in?
super
end
...
end
... and then you check if session[:post] is present, clear and store post.
Il giorno giovedì 14 febbraio 2013 13:05:14 UTC+1, oto iashvili ha scritto:
hiI use devise and cancanmy modelclass PostsController < ApplicationControllerbefore_filter :authenticate_user!, only: [:create, :update, :destroy]...endso an unauthentificate user can access new post form. Now when unauthentificate user submit new or edit forms, he is redirected to login form. But when he logs in, his post is not save in database. Is there anythings to do such as callback if I want the post to be saved ?thanks
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/aFOulOapwfgJ.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment