Results 1 to 5 of 5
Thread: Not equal to conditional
May 14, 2009, 11:48 #1
- Join Date
- Jan 2008
- 0 Post(s)
- 0 Thread(s)
Not equal to conditional
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?
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