Forum: Ruby on Rails MVC newbie question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-05-08 15:16
(Received via mailing list)
All,

Is it possible for a view to call back to a controller method?  If so,
what is the syntax?

=== details
I have a list view that I want to filter out inactive rows based on
several table fields being zero, old, etc.

It would seem I should create a "filtered" method in the controller
(which I have done).

Then invoke if from the view like:

for row in @rows
continue if row.filtered

It is not working.  ie. filtered is undefined.

Thanks
Greg
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
4daf0b71d5d9a3882e583c0e72eaf5dc?d=identicon&s=25 Alan Francis (Guest)
on 2006-05-08 15:30
Greg Freemyer wrote:

> It would seem I should create a "filtered" method in the controller
> (which I have done).
>
> Then invoke if from the view like:
>
> for row in @rows
> continue if row.filtered
>
> It is not working.  ie. filtered is undefined.

row here is a model, not a controller.  Is the method on the Row class ?
It' should be if you are asking each individual row "are you filtered".

If however 'filtered' is not supposed to be a per-row method, but
list-wide...  In your "list" action on controller, create a variable,
this is accessible from the view.

so
BlahController#list
   @filtered = true


views/blah/list.rhtml

if @filtered ....


Des that make sense ?
Alan
4c76f090f2071d34da59c3cf38166587?d=identicon&s=25 Andrew Raines (Guest)
on 2006-05-08 15:35
(Received via mailing list)
Greg Freemyer wrote:

> Is it possible for a view to call back to a controller method?

Sure. ActionController::Helpers::ClassMethods.helper_method():

  http://lnk.nu/api.rubyonrails.org/98s.html

-Drew
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-05-09 00:41
(Received via mailing list)
Thanks, I got that working just fine.

On 5/8/06, Andrew Raines <drewr@pobox.com> wrote:
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
This topic is locked and can not be replied to.