Conrad

I did you suggested but I got this message
Render and/or redirect were called multiple times in this action.
Please note that you may only call render OR redirect, and at most
once per action. Also note that neither redirect nor render terminate
execution of the action, so if you want to exit an action after
redirecting, you need to do something like "redirect_to(...) and
return".

On Apr 26, 3:20 am, Conrad Taylor <[email protected]> wrote:
> On Sun, Apr 25, 2010 at 5:16 PM, Mohammed Alenazi <[email protected]> wrote:
> > Hi
>
> > I have this code
> >  def destroy
> >   �...@property = Property.find(params[:id])
> >   IsAuthorized?(@property.user_id)
> >   �[email protected]
>
> Mohammed, you can write the above as follows:
>
> @property.destroy if IsAuthorized?(@property.user_id)
>
> Good luck,
>
> -Conrad
>
>
>
> >    respond_to do |format|
> >      format.html { redirect_to(properties_url) }
> >      format.xml  { head :ok }
> >    end
> >  end
>
> >  def IsAuthorized?(id)
> >    if current_user.id!= id
> >      flash[:notice] = 'Not authorized '
> >      redirect_to(properties_url)
> >    end
> >   end
>
> > If a not authorized user calls destroy it stills calls
> > @property.destroy.
> > How can I prevent the destory function from calling @property.destroy
> > if the user is not authorized?
>
> > --
> > 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]<rubyonrails-talk%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> 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 
> athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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