On 6 March 2012 15:01, Alpha Blue wrote:
> Here's an example for you:
>
> class Dynamic
> def initialize(variable,value)
> @var,@val = variable,value
> end
> end
>
> test = Dynamic.new('somevar', '')
> test.instance_variable_set(:@brand, 'You see my value')
>
> x = test.instance_variable_get(
Here's an example for you:
class Dynamic
def initialize(variable,value)
@var,@val = variable,value
end
end
test = Dynamic.new('somevar', '')
test.instance_variable_set(:@brand, 'You see my value')
x = test.instance_variable_get(:@brand)
p x
--
Posted via http://www.ruby-forum.com/.
-
Sorry about that - I corrected it above. You can set your own instance
variables using:
self.instance_variable_set(:@var_name, value)
Which will allow you to create dynamic variables.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Go
gon.user = User.first
gon.user.instance_variable_set(:@var_name, value)
--
Posted via http://www.ruby-forum.com/.
--
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 rubyonrails-talk@googlegroups.com.
T
@ALPHA BLUE,
Are you sure, it seems gon only allows for importing ruby/rails variables
into Javascript, and not the other way around?
Thanks again
On Sat, Mar 3, 2012 at 11:43 AM, Abram wrote:
> Thanks guys
>
>
> On Fri, Mar 2, 2012 at 9:50 AM, Alpha Blue wrote:
>
>> You can do that with the
Thanks guys
On Fri, Mar 2, 2012 at 9:50 AM, Alpha Blue wrote:
> You can do that with the Gon gem.
>
> https://github.com/gazay/gon
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> T
You can do that with the Gon gem.
https://github.com/gazay/gon
--
Posted via http://www.ruby-forum.com/.
--
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 rubyonrails-talk@googlegroups.com.
To unsubsc
7 matches
Mail list logo