There could be a before_filter function that looks for the @page variable.

On Wed, Jan 6, 2010 at 9:59 AM, Emre Akkas <[email protected]> wrote:

> The answer to this is probably pretty obvious but I am new to Rails overall
> and cannot seem to be able to figure this out.
>
> In a typical edit, or update method we first find the object that we will
> be working with
>
> def edit
>   @user = User.find(params[:id])
> .
> .
> end
>
> Then we do whatever we need to do with this object.
>
> In the pages controller of Community Engine, these objects magically appear
> themselves
>
>   def destroy
>     @page.destroy
>     flash[:notice] = :page_was_successfully_deleted.l
>     redirect_to admin_pages_path
>   end
>
> How does this destroy method know which object to destroy? This really
> puzzled me as I am trying to add a similar object to pages to my application
> and it does not work if I simply follow the methods that are defined in
> pages_controller.rb.
>
> I can make it work by first retrieving the object as usual @myobject =
> Myobject.find(params[:id]). I would, however, like to understand what is
> happening under the hood and would really appreciate if someone can take a
> moment to explain that to a newbie
>
> Cheers,
> Emre
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "CommunityEngine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<communityengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/communityengine?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "CommunityEngine" 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/communityengine?hl=en.

Reply via email to