Can anyone help with this. I have an edit form which works perfectly.
However I am trying to add one final little bit. This will get the user_id from the cookie and then compare it to the user_id from a query. If the two are not equal to each other then I need to redirect them.
However I can't the conditional part to work. Anyone able to point me right?
Code:def edit_article if request.post? @article = Article.find(params[:id]) if @article.update_attributes(params[:article]) redirect_to :action => 'index' else render :action => 'edit_article' end else @user_id = cookies[:user_id] @article = Article.find(params[:id]) if @article.user_id != @user_id render :text => "This is not your article. Unable to edit." end end end





Bookmarks