hi i have a problem in graphs: am representing data in graphical view and in that i put from date, end date and search button when i select from date, end date and when i press search, values are going into controller through ajax and rendering partial but i can''t able to pass the instance variable in partial view. i have tried the following in the controller: def abc @x1 = Model1.all @y1 = Model2.all render :partial => "partial_name", :@x1 => @x1, :@y1 => @y1 render :partial => "filter_data", :locals => { :@x1=> @x1, :@y1 => @y1 } end in the partial view: <div id="line-example" style="width: 1000px; height: 350px; margin-top: 50px; margin-left: 100px;"></div> <script> window.onload = function () { Morris.Line({ element: ''line-example'', data: [ <% for j in 0...-lafG5gP1o9vtRgLqZ5aouw@public.gmane.org %> {y: ''<%= @y1[j]%>'', a: ''<%= @x1[j] %>''}, <% end %>], xkey: ''y'', ykeys: [''a''], labels: [''Series A''] }); }; </script> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/C0GB8xoBGogJ. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Apr-04 19:38 UTC
Re: rendering instance value to partial views from controller
On 4 April 2013 18:18, Praneeth <praneetheee240-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi i have a problem in graphs: > am representing data in graphical view and in that i put from date, end date > and search button > when i select from date, end date and when i press search, values are going > into controller through ajax and rendering partial but i can''t able to pass > the instance variable in partial view. i have tried the following > in the controller: > def abc > @x1 = Model1.all > @y1 = Model2.all > > render :partial => "partial_name", :@x1 => @x1, :@y1 => @y1 > render :partial => "filter_data", :locals => { :@x1=> @x1, :@y1 => @y1 }render :partial => "filter_data", :locals => { :x1=>@x1, :y1 => @y1 } then use x1 and y1 in the partial. See http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials If that still does not work then insert puts statements in the partial to print the values of things to see what is going on. The print will appear in the server window. Then you will know whether it is getting the data to the view that is the problem or whether it is the view code itself. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Thota praneeth
2013-Apr-05 04:22 UTC
Re: rendering instance value to partial views from controller
i have tried x1 and y1 also still i didn''t get the graph it is showing empty page, but when i render that @x1 or x1 in text_field_tag it is displaying. How can i pass that variables in javascript On Fri, Apr 5, 2013 at 1:08 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 4 April 2013 18:18, Praneeth <praneetheee240-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > hi i have a problem in graphs: > > am representing data in graphical view and in that i put from date, end > date > > and search button > > when i select from date, end date and when i press search, values are > going > > into controller through ajax and rendering partial but i can''t able to > pass > > the instance variable in partial view. i have tried the following > > in the controller: > > def abc > > @x1 = Model1.all > > @y1 = Model2.all > > > > render :partial => "partial_name", :@x1 => @x1, :@y1 => @y1 > > render :partial => "filter_data", :locals => { :@x1=> @x1, :@y1 => @y1 } > > render :partial => "filter_data", :locals => { :x1=>@x1, :y1 => @y1 } > then use x1 and y1 in the partial. See > http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials > > If that still does not work then insert puts statements in the partial > to print the values of things to see what is going on. The print will > appear in the server window. Then you will know whether it is getting > the data to the view that is the problem or whether it is the view > code itself. > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
srikanta mahapatro
2013-Apr-05 04:29 UTC
Re: rendering instance value to partial views from controller
We have two options. The first option is the suggested solution. 1. Change all instance variables to a local variable and pass it to the partial with the locals argument of render. 2. Set the instance variable before the partial is rendered. Partials have access to all the instance variables that your controller sets. On Fri, Apr 5, 2013 at 1:08 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 4 April 2013 18:18, Praneeth <praneetheee240-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > hi i have a problem in graphs: > > am representing data in graphical view and in that i put from date, end > date > > and search button > > when i select from date, end date and when i press search, values are > going > > into controller through ajax and rendering partial but i can''t able to > pass > > the instance variable in partial view. i have tried the following > > in the controller: > > def abc > > @x1 = Model1.all > > @y1 = Model2.all > > > > render :partial => "partial_name", :@x1 => @x1, :@y1 => @y1 > > render :partial => "filter_data", :locals => { :@x1=> @x1, :@y1 => @y1 } > > render :partial => "filter_data", :locals => { :x1=>@x1, :y1 => @y1 } > then use x1 and y1 in the partial. See > http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials > > If that still does not work then insert puts statements in the partial > to print the values of things to see what is going on. The print will > appear in the server window. Then you will know whether it is getting > the data to the view that is the problem or whether it is the view > code itself. > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Thanks & Regards Srikant Mahapatro Mobile : +919439778819 Email : mailsrikanta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Thota praneeth
2013-Apr-05 17:06 UTC
Re: rendering instance value to partial views from controller
yeah i have changed to local variables and passed to partial by debugging in firefox i got the expected values in javascript(partial view) but graph is not displaying according to expected values On Fri, Apr 5, 2013 at 9:27 PM, Gintautas Å imkus <dihitales-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> First of all I suggest you to try firebug in firefox. Then you can see > exactly what is returned for your request. In your case you might need > escaping javascript with javascript_escape. > > > 2013/4/5 srikanta mahapatro <mailsrikanta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> We have two options. The first option is the suggested solution. >> >> 1. >> >> Change all instance variables to a local variable and pass it to the >> partial with the locals argument of render. >> 2. >> >> Set the instance variable before the partial is rendered. Partials >> have access to all the instance variables that your controller sets. >> >> >> >> >> On Fri, Apr 5, 2013 at 1:08 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >>> On 4 April 2013 18:18, Praneeth <praneetheee240-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > hi i have a problem in graphs: >>> > am representing data in graphical view and in that i put from date, >>> end date >>> > and search button >>> > when i select from date, end date and when i press search, values are >>> going >>> > into controller through ajax and rendering partial but i can''t able to >>> pass >>> > the instance variable in partial view. i have tried the following >>> > in the controller: >>> > def abc >>> > @x1 = Model1.all >>> > @y1 = Model2.all >>> > >>> > render :partial => "partial_name", :@x1 => @x1, :@y1 => @y1 >>> > render :partial => "filter_data", :locals => { :@x1=> @x1, :@y1 => @y1 >>> } >>> >>> render :partial => "filter_data", :locals => { :x1=>@x1, :y1 => @y1 } >>> then use x1 and y1 in the partial. See >>> http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials >>> >>> If that still does not work then insert puts statements in the partial >>> to print the values of things to see what is going on. The print will >>> appear in the server window. Then you will know whether it is getting >>> the data to the view that is the problem or whether it is the view >>> code itself. >>> >>> Colin >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> -- >> Thanks & Regards >> Srikant Mahapatro >> Mobile : +919439778819 >> Email : mailsrikanta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Pagarbiai, > Gintautas > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.