Passing options

6 views
Skip to first unread message

Josh Cohen

unread,
May 7, 2014, 11:44:46 PM5/7/14
to roar...@googlegroups.com
I must be missing something obvious.
How can I pass an option (say an instance variable) from a controller to a representer and use it by direct reference.

In my links section, I need the value of a controller instance variable for use in a link path.
Eg
 link :self do
      AHOST + "/proxy/#{@crm}/people/#{id}"
 end


Josh Cohen  jos...@gmail.com | @joshco | LinkedIn | GitHub  | OSDI opensupporter.org
"If [OSDI] succeeds, it could usher in the next chapter in political technology." - Washington Post

Nick Sutterer

unread,
May 8, 2014, 12:15:52 AM5/8/14
to roar...@googlegroups.com
Try this:

representer.to_json(crm: @crm)

Then, the link block will retrieve the options: https://github.com/apotonick/roar#passing-options

Nick




--
You received this message because you are subscribed to the Google Groups "Roar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roar-talk+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh Cohen

unread,
May 8, 2014, 12:20:01 AM5/8/14
to roar...@googlegroups.com

Ah, got it.  My problem was that I wasn't including the opts on the block.

Another related thing..

How would I use it in an if statement?

 

Eg

If @crm=="foo"

  link :self do

        AHOST + "/proxy/#{@crm}/people/#{id}"

   end

Nick Sutterer

unread,
May 8, 2014, 12:20:57 AM5/8/14
to roar...@googlegroups.com
Do the if inside the link block, when it returns nil it's not rendered.
Reply all
Reply to author
Forward
0 new messages