Abram
2012-Feb-29 19:29 UTC
Please help. I would like to assign a java variable to a ruby instance variable.
Thanks in advance for any help on this. I would like to search my DB for records using a Model.where request... Using jquery I have access to the text within the select option chosen from a drop box. Now, if only I could take this text and assign it to a ruby instance variable, such as @brand.... I could then insert the value into the ''where'' request and pull the records corresponding to the selected option. It seems possible to assign a ruby variable to a jquery var, but not the other way around. Is there, or could there be, a ruby function to help with this? Thanks, Abram -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2012-Mar-01 13:50 UTC
Re: Please help. I would like to assign a java variable to a ruby instance variable.
On Feb 29, 2012, at 2:29 PM, Abram wrote:> Thanks in advance for any help on this. > > I would like to search my DB for records using a Model.where > request... Using jquery I have access to the text within the select > option chosen from a drop box. Now, if only I could take this text and > assign it to a ruby instance variable, such as @brand.... I could then > insert the value into the ''where'' request and pull the records > corresponding to the selected option. > > It seems possible to assign a ruby variable to a jquery var, but not > the other way around. Is there, or could there be, a ruby function to > help with this?Have a google for Ajax request. You will need to respond to an xhr request in your controller and return whatever result you need in Rails. From the jQuery (JavaScript) side, you''re doing a post request, just not refreshing the page as you do so. Walter> > Thanks, > Abram > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alpha Blue
2012-Mar-01 20:50 UTC
Re: Please help. I would like to assign a java variable to a ruby instance variable.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Abram
2012-Mar-02 22:43 UTC
Re: Re: Please help. I would like to assign a java variable to a ruby instance variable.
Thanks guys On Fri, Mar 2, 2012 at 9:50 AM, Alpha Blue <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Abram
2012-Mar-05 19:25 UTC
Re: Re: Please help. I would like to assign a java variable to a ruby instance variable.
@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 <funkdified-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks guys > > > On Fri, Mar 2, 2012 at 9:50 AM, Alpha Blue <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alpha Blue
2012-Mar-06 14:35 UTC
Re: Please help. I would like to assign a java variable to a ruby instance variable.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alpha Blue
2012-Mar-06 14:37 UTC
Re: Please help. I would like to assign a java variable to a ruby instance variable.
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 Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alpha Blue
2012-Mar-06 15:01 UTC
Re: Please help. I would like to assign a java variable to a ruby instance variable.
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/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2012-Mar-06 15:22 UTC
Re: Re: Please help. I would like to assign a java variable to a ruby instance variable.
On 6 March 2012 15:01, Alpha Blue <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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(:@brand)@Abram is this actually what you are wanting to do, or are you just trying to get a value from a variable in your jQuery code in the browser passed as a parameter in a request to the server in order to use it in a db lookup? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.