Hi,
This is actually my first question on this list.
Im using Ruby on Rails and im adding an array of users into a session object. The problem is when I add it to the session I get the following error
Status: 500 Internal Server Error
singleton can't be dumped
The problem is my user class called Expert is not a singleton class. The following is a snippet of my controller code.
def search
..
if @experts.empty?
@experts = expert_word_search(@search_params)
@page_results = paginate_array(@experts.uniq)
end
session[:search_results] = @page_results
session[:complete_search_results] = @experts
..
end
I realize that storing the page_results in session is a bad design
choice but my question is why does it throw a "singleton can't be
dumped error". Since my expert class is not a singleton class and the
method expert_word_search belongs to a module which handles the search
logic. Im also only including my module. I also tried to find if im unintentionally creating any singletons objects using the singleton_methods method but im not.
--
You received this message because you are subscribed to the Google Groups "BANGALORE RUG-Ruby Users Group" group.
To post to this group, send an email to bangal...@googlegroups.com.
To unsubscribe from this group, send email to bangalorerug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bangalorerug?hl=en-GB.
Cheers,
Sidu.
http://blog.sidu.in
http://twitter.com/ponnappa
Siddharth Ravichandran wrote:
> Thanks man. It totally works.
>
> What i dont understand is the reason for the error. the minute i
> change the format to JSON it works. But I dont understand where the
> singleton class is getting created.
>
>
>
> On Mon, Mar 29, 2010 at 12:38 PM, Siddharth Ravichandran
> <sid.ravi...@gmail.com <mailto:sid.ravi...@gmail.com>> wrote:
>
> Hi Swanand,
>
> Thanks for the reply . But im actually using ActiveRecord Session
> Store. Could that still be the problem?
>
> On Mon, Mar 29, 2010 at 12:35 PM, Swanand Pagnis
> <swanand...@gmail.com <mailto:swanand...@gmail.com>> wrote:
>
> I guess this is the 'cookie overflow' error. Each cookie can
> contain only 4kb of data. My guess is @post_results when
> serialized by Marshall Dump is bigger than 4kb. Try putting
> only post IDs in some other form rather than an ActiveRecord
> Collection (in JSON format for eg). This might help solve the
> problem.
>
> On Mon, Mar 29, 2010 at 4:48 PM, Siddharth Ravichandran
> <sid.ravi...@gmail.com
> <mailto:sid.ravi...@gmail.com>> wrote:
>
> Hi,
>
> This is actually my first question on this list.
>
> Im using Ruby on Rails and im adding an array of users
> into a session object. The problem is when I add it to the
> session I get the following error
>
> |Status: 500 Internal Server Error singleton can't be dumped|
>
> The problem is my user class called Expert is not a
> singleton class. The following is a snippet of my
> controller code.
>
>
> *|def search
> ..
> if @experts.empty?
>
> @experts = expert_word_search(@search_params)
>
> @page_results = paginate_array(@experts.uniq)
>
> end
> session[:search_results] = @page_results
>
> session[:complete_search_results] = @experts
>
> ..
> end
> |*
> <mailto:bangal...@googlegroups.com>.
> To unsubscribe from this group, send email to
> bangalorerug...@googlegroups.com
> <mailto:bangalorerug%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/group/bangalorerug?hl=en-GB.
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "BANGALORE RUG-Ruby Users Group" group.
> To post to this group, send an email to
> bangal...@googlegroups.com
> <mailto:bangal...@googlegroups.com>.
> To unsubscribe from this group, send email to
> bangalorerug...@googlegroups.com
> <mailto:bangalorerug%2Bunsu...@googlegroups.com>.
Next question is - what segment of the app stack are you trying to
optimise? Put another way, what exactly is preventing you from *not*
caching anything and just repeating the search each time; why is the
search not fast enough to be used as is? (sorry, that's a lot of
questions I'm throwing at you)
The reason I even brought it up is (and please forgive me if you've come
across this already) that generally you try to put as little as possible
in your session. It's that anti-pattern which I've heard called many
things, but is best described by 'Session as Database'.
> <mailto:sid.ravi...@gmail.com
> <mailto:sid.ravi...@gmail.com>>> wrote:
>
> Hi Swanand,
>
> Thanks for the reply . But im actually using ActiveRecord
> Session
> Store. Could that still be the problem?
>
> On Mon, Mar 29, 2010 at 12:35 PM, Swanand Pagnis
> <swanand...@gmail.com <mailto:swanand...@gmail.com>
> <mailto:swanand...@gmail.com
> <mailto:swanand...@gmail.com>>> wrote:
>
> I guess this is the 'cookie overflow' error. Each
> cookie can
> contain only 4kb of data. My guess is @post_results when
> serialized by Marshall Dump is bigger than 4kb. Try putting
> only post IDs in some other form rather than an
> ActiveRecord
> Collection (in JSON format for eg). This might help
> solve the
> problem.
>
> On Mon, Mar 29, 2010 at 4:48 PM, Siddharth Ravichandran
> <sid.ravi...@gmail.com
> <mailto:sid.ravi...@gmail.com>
> <mailto:sid.ravi...@gmail.com
> <mailto:bangal...@googlegroups.com
> <mailto:bangal...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> bangalorerug...@googlegroups.com
> <mailto:bangalorerug%2Bunsu...@googlegroups.com>
> <mailto:bangalorerug%2Bunsu...@googlegroups.com
> <mailto:bangalorerug%252Buns...@googlegroups.com>>.
>
> For more options, visit this group at
> http://groups.google.com/group/bangalorerug?hl=en-GB.
>
>
> -- You received this message because you are
> subscribed to the
> Google Groups "BANGALORE RUG-Ruby Users Group" group.
> To post to this group, send an email to
> bangal...@googlegroups.com
> <mailto:bangal...@googlegroups.com>
> <mailto:bangal...@googlegroups.com
> <mailto:bangal...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> bangalorerug...@googlegroups.com
> <mailto:bangalorerug%2Bunsu...@googlegroups.com>
> <mailto:bangalorerug%2Bunsu...@googlegroups.com
> <mailto:bangalorerug%252Buns...@googlegroups.com>>.