The following rails 2.3.x code is not working in rails 3 beta 4:
def
render_crud_table(obj,controller_name,columns,search_fields_array,status_array,actions)
render :partial => ''shared/crud_maint_table'', :object
=> obj,
:locals => {:controller_name => controller_name, :columns =>
columns, :search_fields_array => search_fields_array, :status_array =>
status_array, :actions => actions}
end
The partial _crud_maint_table in the shared folder has this code
snippet:
...
- crud_maint_table.each do |a_rec|
%tr{ :class => cycle("odd","even") }
- columns.each_with_index do |col, i|
%td{ :class => (i == 0 ? ''first'' : nil) }
...
See the crud_maint_table.each loop? That works in rails 2.3.x but not
in rails 3.
Please advise.
thanks.
Bharat
--
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.
Bharat Ruparel wrote:> The following rails 2.3.x code is not working in rails 3 beta 4: > > def > render_crud_table(obj,controller_name,columns,search_fields_array,status_array,actions) > render :partial => ''shared/crud_maint_table'', :object => obj, > :locals => {:controller_name => controller_name, :columns => > columns, :search_fields_array => search_fields_array, :status_array => > status_array, :actions => actions} > end > > The partial _crud_maint_table in the shared folder has this code > snippet: > > ... > - crud_maint_table.each do |a_rec| > %tr{ :class => cycle("odd","even") } > - columns.each_with_index do |col, i| > %td{ :class => (i == 0 ? ''first'' : nil) } > ... > > See the crud_maint_table.each loop? That works in rails 2.3.x but not > in rails 3. > Please advise. > thanks. > BharatWell,I met the same problem. I had some debug, it seems that rails treat :object as :collection, so the crud_maint_table actually is the first element of the array obj. I''m not sure it''s a bug or sth changed since 3 and I haven''t found any solution -- 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.
Zhuhao Wang wrote:> Bharat Ruparel wrote: >> The following rails 2.3.x code is not working in rails 3 beta 4: >> >> def >> render_crud_table(obj,controller_name,columns,search_fields_array,status_array,actions) >> render :partial => ''shared/crud_maint_table'', :object => obj, >> :locals => {:controller_name => controller_name, :columns => >> columns, :search_fields_array => search_fields_array, :status_array => >> status_array, :actions => actions} >> end >> >> The partial _crud_maint_table in the shared folder has this code >> snippet: >> >> ... >> - crud_maint_table.each do |a_rec| >> %tr{ :class => cycle("odd","even") } >> - columns.each_with_index do |col, i| >> %td{ :class => (i == 0 ? ''first'' : nil) } >> ... >> >> See the crud_maint_table.each loop? That works in rails 2.3.x but not >> in rails 3. >> Please advise. >> thanks. >> Bharat > > > Well,I met the same problem. > I had some debug, it seems that rails treat :object as :collection, so > the crud_maint_table actually is the first element of the array obj. > I''m not sure it''s a bug or sth changed since 3 and I haven''t found any > solutionWhen I tried to use :locals, there are some strange text: #<Tutor:0xd3065c0>#<Tutor:0xd2e32b0>#<Tutor:0xd2e3250>#<Tutor:0xd2e3118>#<Tutor:0xd2e30b8>#<Tutor:0xd2e3058>#<Tutor:0xd2e2ff8>#<Tutor:0xd2e2f98>#<Tutor:0xd2e2f38>#<Tutor:0xd2e2ea8>#<Tutor:0xd2e2d40>#<Tutor:0xd2e2cc8>#<Tutor:0xd2e2c08>#<Tutor:0xd2e2b78>#<Tutor:0xd2e2b18> before the content of the partial ,seems like the ID of the elements of the array I passed in.......can''t get rid of it............. -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
those are the classes you are forgeting to call a property in the view,
seems like you are doing this
<%= @tutors.each do |tutor|%>
<%= tutor%>
it should be
<%= @tutors.each do |tutor|%>
<%= tutor.name %>
On Mon, Sep 13, 2010 at 6:14 AM, Zhuhao Wang
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Zhuhao Wang wrote:
> > Bharat Ruparel wrote:
> >> The following rails 2.3.x code is not working in rails 3 beta 4:
> >>
> >> def
> >>
>
render_crud_table(obj,controller_name,columns,search_fields_array,status_array,actions)
> >> render :partial =>
''shared/crud_maint_table'', :object => obj,
> >> :locals => {:controller_name => controller_name,
:columns =>
> >> columns, :search_fields_array => search_fields_array,
:status_array =>
> >> status_array, :actions => actions}
> >> end
> >>
> >> The partial _crud_maint_table in the shared folder has this code
> >> snippet:
> >>
> >> ...
> >> - crud_maint_table.each do |a_rec|
> >> %tr{ :class => cycle("odd","even") }
> >> - columns.each_with_index do |col, i|
> >> %td{ :class => (i == 0 ? ''first'' :
nil) }
> >> ...
> >>
> >> See the crud_maint_table.each loop? That works in rails 2.3.x but
not
> >> in rails 3.
> >> Please advise.
> >> thanks.
> >> Bharat
> >
> >
> > Well,I met the same problem.
> > I had some debug, it seems that rails treat :object as :collection, so
> > the crud_maint_table actually is the first element of the array obj.
> > I''m not sure it''s a bug or sth changed since 3 and I
haven''t found any
> > solution
>
> When I tried to use :locals, there are some strange text:
>
>
>
#<Tutor:0xd3065c0>#<Tutor:0xd2e32b0>#<Tutor:0xd2e3250>#<Tutor:0xd2e3118>#<Tutor:0xd2e30b8>#<Tutor:0xd2e3058>#<Tutor:0xd2e2ff8>#<Tutor:0xd2e2f98>#<Tutor:0xd2e2f38>#<Tutor:0xd2e2ea8>#<Tutor:0xd2e2d40>#<Tutor:0xd2e2cc8>#<Tutor:0xd2e2c08>#<Tutor:0xd2e2b78>#<Tutor:0xd2e2b18>
>
> before the content of the partial ,seems like the ID of the elements of
> the array I passed in.......can''t get rid of it.............
> --
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
radhames brito wrote:> those are the classes you are forgeting to call a property in the view, > > > seems like you are doing this > > <%= @tutors.each do |tutor|%> > <%= tutor%> > > it should be > > <%= @tutors.each do |tutor|%> > <%= tutor.name %>I tried, <%= @tutors.each do |tutor|%> this line should be <% @tutors.each do |tutor|%> fix this,thx I also find an artical http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 says :object is removed,but you can find an offcial artical here http://edgeguides.rubyonrails.org/layouts_and_rendering.html which says :object is still what I expect....... -- 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.
surely, got confused there. On Mon, Sep 13, 2010 at 10:08 AM, Zhuhao Wang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> radhames brito wrote: > > those are the classes you are forgeting to call a property in the view, > > > > > > seems like you are doing this > > > > <%= @tutors.each do |tutor|%> > > <%= tutor%> > > > > it should be > > > > <%= @tutors.each do |tutor|%> > > <%= tutor.name %> > > I tried, > > <%= @tutors.each do |tutor|%> > > this line should be > > <% @tutors.each do |tutor|%> > > fix this,thx > > > I also find an artical > http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 says > :object is removed,but you can find an offcial artical here > http://edgeguides.rubyonrails.org/layouts_and_rendering.html which says > :object is still what I expect....... > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
What was the problem? how did you solve it? On Mon, Sep 13, 2010 at 10:12 AM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> surely, got confused there. > > > On Mon, Sep 13, 2010 at 10:08 AM, Zhuhao Wang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> radhames brito wrote: >> > those are the classes you are forgeting to call a property in the view, >> > >> > >> > seems like you are doing this >> > >> > <%= @tutors.each do |tutor|%> >> > <%= tutor%> >> > >> > it should be >> > >> > <%= @tutors.each do |tutor|%> >> > <%= tutor.name %> >> >> I tried, >> >> <%= @tutors.each do |tutor|%> >> >> this line should be >> >> <% @tutors.each do |tutor|%> >> >> fix this,thx >> >> >> I also find an artical >> http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 says >> :object is removed,but you can find an offcial artical here >> http://edgeguides.rubyonrails.org/layouts_and_rendering.html which says >> :object is still what I expect....... >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
Hello, You are right about the object deprecation in Rails 3. I solved the problem the same way you did. Instead of passing the table name in object. I now pass it in the locals hash. Hope this helps. Bharat -- 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.
radhames brito wrote:> What was the problem? how did you solve it?render :partial =>''sth'',:object => @sth is not working in rails 3,it pass the first element of the array @sth(I''m not sure what would happen if @sth is not an array),thus you can''t call each in the template.You have to use :locals =>{:sth =>@sth}.Seems a little complicated,is it a bug or some change not mentioned in the changelog? Before I realize this I changed the view a little,added <%= Tutor.each .....%>,and got that text. -- 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.
change this render :partial =>''sth'',:object => @sth to this , and call the array in the controller like this @sths then create a partial with the singular , _sth.html.erb render :partial =>@sths i always do it that way and works perfectly On Mon, Sep 13, 2010 at 10:23 AM, Zhuhao Wang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> radhames brito wrote: > > What was the problem? how did you solve it? > > render :partial =>''sth'',:object => @sth > > is not working in rails 3,it pass the first element of the array > @sth(I''m not sure what would happen if @sth is not an array),thus you > can''t call each in the template.You have to use :locals =>{:sth > =>@sth}.Seems a little complicated,is it a bug or some change not > mentioned in the changelog? > > Before I realize this I changed the view a little,added <%= Tutor.each > .....%>,and got that text. > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.