On Sun, Apr 25, 2010 at 5:20 PM, Conrad Taylor <[email protected]> wrote:

> Mohammed, you can write the above as follows:
> @property.destroy if IsAuthorized?(@property.user_id)

Well, you could, *if* IsAuthorized? -- which idiomatically should
be is_authorized? -- returned a boolean value :-)

>>  def IsAuthorized?(id)
>>    if current_user.id!= id
>>      flash[:notice] = 'Not authorized '
>>      redirect_to(properties_url)
>>    end
>>   end

e.g.

def is_authorized?(id)
   current_user.id == id
end

-- 
Hassan Schroeder ------------------------ [email protected]
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to