In my controller show method i have two instance variables which have large amount of data and take much time to fetch from remote system. shown below def show @graph = Koala::Facebook::GraphAPI.new(session[:fbuser] ["credentials"]["token"]) @friends = @graph.get_connections("me", "friends") @friends =@friends.to_a end in the same controller I have another action which requires same data. shown below def list @graph ||= Koala::Facebook::GraphAPI.new(session[:fbuser] ["credentials"]["token"]) @friends ||= @graph.get_connections("me", "friends") @friends|| =@friends.to_a end which are loading every time even i used || (or) in fetching. Any help regarding to re usage of instance variables of one action in another action of same controller. Thank You -- 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.
Rajarshi
2011-Sep-19 12:22 UTC
Re: how to get instance variables in another action in rails 3
Yes Because u d onot know filter Please read before after around filter u will get On Mon, Sep 19, 2011 at 5:43 PM, subbarao <subbarao.kly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In my controller show method i have two instance variables which have > large amount of data and take much time to fetch from remote system. > shown below > def show > @graph = Koala::Facebook::GraphAPI.new(session[:fbuser] > ["credentials"]["token"]) > @friends = @graph.get_connections("me", "friends") > @friends =@friends.to_a > > end > > in the same controller I have another action which requires same data. > shown below > > def list > > @graph ||= Koala::Facebook::GraphAPI.new(session[:fbuser] > ["credentials"]["token"]) > @friends ||= @graph.get_connections("me", "friends") > @friends|| =@friends.to_a > > end > > which are loading every time even i used || (or) in fetching. > Any help regarding to re usage of instance variables of one action in > another action of same controller. > > Thank You > > -- > 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.
subbarao
2011-Sep-19 12:27 UTC
Re: how to get instance variables in another action in rails 3
I know filter concept, but how we can apply that concept hear to work with instance variables? give me one example please . On Sep 19, 5:22 pm, Rajarshi <rdas2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes Because u d onot know filter > Please read before after around filter u will get > > On Mon, Sep 19, 2011 at 5:43 PM, subbarao <subbarao....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > In my controller show method i have two instance variables which have > > large amount of data and take much time to fetch from remote system. > > shown below > > def show > > @graph = Koala::Facebook::GraphAPI.new(session[:fbuser] > > ["credentials"]["token"]) > > @friends = @graph.get_connections("me", "friends") > > @friends =...-FTTMvTJegw1Yi9NPxK1VTg@public.gmane.org_a > > > end > > > in the same controller I have another action which requires same data. > > shown below > > > def list > > > @graph ||= Koala::Facebook::GraphAPI.new(session[:fbuser] > > ["credentials"]["token"]) > > @friends ||= @graph.get_connections("me", "friends") > > @friends|| =...-FTTMvTJegw1Yi9NPxK1VTg@public.gmane.org_a > > > end > > > which are loading every time even i used || (or) in fetching. > > Any help regarding to re usage of instance variables of one action in > > another action of same controller. > > > Thank You > > > -- > > 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Sep-19 12:44 UTC
Re: how to get instance variables in another action in rails 3
On 19 September 2011 13:13, subbarao <subbarao.kly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In my controller show method i have two instance variables which have > large amount of data and take much time to fetch from remote system. > shown below > def show > @graph = Koala::Facebook::GraphAPI.new(session[:fbuser] > ["credentials"]["token"]) > @friends = @graph.get_connections("me", "friends") > @friends =-FTTMvTJegw1Yi9NPxK1VTg@public.gmane.org_a > > end > > in the same controller I have another action which requires same data. > shown below > > def list > > @graph ||= Koala::Facebook::GraphAPI.new(session[:fbuser] > ["credentials"]["token"]) > @friends ||= @graph.get_connections("me", "friends") > @friends|| =-FTTMvTJegw1Yi9NPxK1VTg@public.gmane.org_a > > end > > which are loading every time even i used || (or) in fetching. > Any help regarding to re usage of instance variables of one action in > another action of same controller.I think the only way would be to cache the data locally in some way, either save it in a file or in the database and then retrieve it in the next action. If you are using the data to generate the same partial display then you may be able to use the built in caching mechanism in rails. See the Rails Guide on caching. In fact it may be worth looking at that anyway. 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.
subbarao
2011-Sep-19 13:06 UTC
Re: how to get instance variables in another action in rails 3
On Monday 19 September 2011 06:14 PM, Colin Law wrote:> On 19 September 2011 13:13, subbarao<subbarao.kly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> In my controller show method i have two instance variables which have >> large amount of data and take much time to fetch from remote system. >> shown below >> def show >> @graph = Koala::Facebook::GraphAPI.new(session[:fbuser] >> ["credentials"]["token"]) >> @friends = @graph.get_connections("me", "friends") >> @friends =@friends.to_a >> >> end >> >> in the same controller I have another action which requires same data. >> shown below >> >> def list >> >> @graph ||= Koala::Facebook::GraphAPI.new(session[:fbuser] >> ["credentials"]["token"]) >> @friends ||= @graph.get_connections("me", "friends") >> @friends|| =@friends.to_a >> >> end >> >> which are loading every time even i used || (or) in fetching. >> Any help regarding to re usage of instance variables of one action in >> another action of same controller. > I think the only way would be to cache the data locally in some way, > either save it in a file or in the database and then retrieve it in > the next action. > > If you are using the data to generate the same partial display then > you may be able to use the built in caching mechanism in rails. See > the Rails Guide on caching. In fact it may be worth looking at that > anyway. > > Colin >Yes if i use catching in my application view the size limit exceeding . even I tried with passing these values throw params[:var] argument also failing Too large http request error. I also tried with Class variables to store data like @@graph and @@friends but no use those variables not at all storing data. any other way please. -- 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
2011-Sep-19 14:15 UTC
Re: how to get instance variables in another action in rails 3
On 19 September 2011 14:06, subbarao <subbarao.kly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Monday 19 September 2011 06:14 PM, Colin Law wrote: >> >> On 19 September 2011 13:13, subbarao<subbarao.kly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> In my controller show method i have two instance variables which have >>> large amount of data and take much time to fetch from remote system. >>> shown below >>> def show >>> @graph = Koala::Facebook::GraphAPI.new(session[:fbuser] >>> ["credentials"]["token"]) >>> @friends = @graph.get_connections("me", "friends") >>> @friends =-FTTMvTJegw1Yi9NPxK1VTg@public.gmane.org_a >>> >>> end >>> >>> in the same controller I have another action which requires same data. >>> shown below >>> >>> def list >>> >>> @graph ||= Koala::Facebook::GraphAPI.new(session[:fbuser] >>> ["credentials"]["token"]) >>> @friends ||= @graph.get_connections("me", "friends") >>> @friends|| =-FTTMvTJegw1Yi9NPxK1VTg@public.gmane.org_a >>> >>> end >>> >>> which are loading every time even i used || (or) in fetching. >>> Any help regarding to re usage of instance variables of one action in >>> another action of same controller. >> >> I think the only way would be to cache the data locally in some way, >> either save it in a file or in the database and then retrieve it in >> the next action. >> >> If you are using the data to generate the same partial display then >> you may be able to use the built in caching mechanism in rails. See >> the Rails Guide on caching. In fact it may be worth looking at that >> anyway. >> >> Colin >> > Yes if i use catching in my application view the size limit exceedingWhat do you mean catching? If you mean the rails caching then there is no size limit.> . even > I tried with passing these values throw params[:var] argument also failing > Too large http request error. > I also tried with Class variables to store data like @@graph and @@friends > but no use those variables not at all storing data. any other way please.Yes, the ways I suggested, in a file, database, possibly using the rails caching to help. Have you read the guide? 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.
Frederick Cheung
2011-Sep-19 15:29 UTC
Re: how to get instance variables in another action in rails 3
On Sep 19, 3:15 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 19 September 2011 14:06, subbarao <subbarao....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Yes if i use catching in my application view the size limit exceeding > > What do you mean catching? If you mean the rails caching then there > is no size limit.Depends on the store - for example memcache won''t store anything larger than 1Mb It might be preferable to store the objects that are slow to fetch rather than the view itself, for example @friends = Rails.cache.fetch("friends_for_#{session[:fbuser] ["credentials"]["token"]}") do graph = Koala::Facebook::GraphAPI.new(session[:fbuser] ["credentials"]["token"]) graph.get_connections("me", "friends").to_a end Fred> > > . even > > I tried with passing these values throw params[:var] argument also failing > > Too large http request error. > > I also tried with Class variables to store data like @@graph and @@friends > > but no use those variables not at all storing data. any other way please. > > Yes, the ways I suggested, in a file, database, possibly using the > rails caching to help. Have you read the guide? > > 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.
Colin Law
2011-Sep-19 15:41 UTC
Re: Re: how to get instance variables in another action in rails 3
On 19 September 2011 16:29, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Sep 19, 3:15 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 19 September 2011 14:06, subbarao <subbarao....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > Yes if i use catching in my application view the size limit exceeding >> >> What do you mean catching? If you mean the rails caching then there >> is no size limit. > > Depends on the store - for example memcache won''t store anything > larger than 1MbI stand corrected, thanks Fred. I have only used file caching. Once again it is shown that a little knowledge is a dangerous thing.> It might be preferable to store the objects that are slow to fetch > rather than the view itself, for example > > @friends = Rails.cache.fetch("friends_for_#{session[:fbuser] > ["credentials"]["token"]}") do > graph = Koala::Facebook::GraphAPI.new(session[:fbuser] > ["credentials"]["token"]) > graph.get_connections("me", "friends").to_a > endThat looks a good way to go. 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.