API:List mark records doesn't work

120 views
Skip to first unread message

Andrey Novikov

unread,
Jun 11, 2012, 6:54:54 AM6/11/12
to actives...@googlegroups.com
I'm trying to get the mark_records feature work in latest Active Scaddold (v3.2.11 and latest master branch commit on Rails 3.2.5), but it doesn't.

I'm trying to do it according to the topic Looking for guidance on :mark_records, in such manner:

class Admin::Users::AdminsController < Admin::Users::UsersController
  active_scaffold :admin do |conf|
    conf.list.mark_records = true
  end
end

Nothing happens (even after server restart). No checkboxes displaying. Well, add next part of code:

  before_filter :blah
 
  def blah
    self.class.send :include, ActiveScaffold::Actions::Mark
    active_scaffold_config.list.mark_records = true
  end

Again, nothing. If I'll put debugger into that method - I'll be able to read the marked_records set and add items to it (and read'em back on next request).
Well, in the source I've found the :marked column, try to add it:

class Admin::Users::AdminsController < Admin::Users::UsersController
  active_scaffold :admin do |conf|
    conf.list.mark_records = true
  end
  before_filter :blah
 
  def blah
    self.class.send :include, ActiveScaffold::Actions::Mark
    active_scaffold_config.list.mark_records = true
    active_scaffold_config.list.columns << :marked
  end
end

And after that on the next request I've got the fatality:

RuntimeError in Admin/users/admins#index

Showing /home/envek/.rvm/gems/ruby-1.9.3-p125/bundler/gems/active_scaffold-6fa9146cbd52/frontends/default/views/_list_column_headings.html.erb where line #9 raised:

Mark is not enabled. Please enable it or remove any references in your configuration (e.g. config.mark.columns = [...]).

What I'm doing wrong? Where I should enable it actually? Please, help, if anybody can.

Nick Rogers

unread,
Jun 11, 2012, 9:49:41 AM6/11/12
to actives...@googlegroups.com
conf.actions.add :mark


--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group.
To view this discussion on the web visit https://groups.google.com/d/msg/activescaffold/-/9r3NYden0pEJ.
To post to this group, send email to actives...@googlegroups.com.
To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.

Andrey Novikov

unread,
Jun 12, 2012, 3:22:53 AM6/12/12
to actives...@googlegroups.com
Nick, thanks a lot!

I've added an example to the API: List wiki page. If you have time and wish, please review and fix it (it's incomplete!).

And, anyway, it doesn't work. Checkboxes are checkable, on checkbox click the POST request goes to the server (with an OK answer), but if I'm moving to the another scaffold page, and return back — selection sometimes disappears (and sometimes partially). If I'm calling my method, the marked_records method always returns empty set. What's wrong now?

I've disabled browser cache in firebug, change rails session store from cookie to cache, tries to clear rails temp folder. The behavior stays weird.

My code is:

class PeriodsController < ApplicationController
  active_scaffold :period do |conf|
    conf.list.mark_records = true
    conf.actions.add :mark
    conf.action_links.add :delete_selected, :type => :collection, :method => :delete
    conf.columns = [:date, :published]
    conf.show.link = false
  end

  def delete_selected
    logger.debug "Marked records: #{marked_records.count}"
    marked_records.each { |record| record.destroy! }
    head :ok
  end

end

понедельник, 11 июня 2012 г., 23:49:41 UTC+10 пользователь Nick Rogers написал:
conf.actions.add :mark

To post to this group, send email to activescaffold@googlegroups.com.
To unsubscribe from this group, send email to activescaffold+unsubscribe@googlegroups.com.

Sergio Cambra

unread,
Jun 13, 2012, 11:34:57 AM6/13/12
to actives...@googlegroups.com
I have fixed mark action. I haven't tried it in 3.x version yet

Also, don't use conf.list.mark_records = true, it wasn't used and I have
removed it. Only add :mark action.

I have updated API

On Martes, 12 de junio de 2012 00:22:53 Andrey Novikov escribió:
> Nick, thanks a lot!
>
> I've added an example to the API:
> List<https://github.com/activescaffold/active_scaffold/wiki/API:-List>wiki
> page. If you have time and wish, please
> review<https://github.com/activescaffold/active_scaffold/wiki/API:-List/_co
> mpare/dbd504cf5ac60e79c4ffa4ff26d3bef5d73b5c08...a5f3aecda91a41f4d113fd6a59e
> bc72a10782be8>and fix it (it's incomplete!).
>
> And, anyway, it doesn't work. Checkboxes are checkable, on checkbox click
> the POST request goes to the server (with an OK answer), but if I'm moving
> to the another scaffold page, and return back -- selection
> *sometimes*disappears (and sometimes partially). If I'm calling my method,
> the marked_records method *always* returns empty set. What's wrong now?
> >> :mark_records<https://groups.google.com/forum/?fromgroups#%21topic/active
> >> :scaffold/btRm42JO9Hk>,>>
> >> in such manner:
> >>
> >> class Admin::Users::AdminsController < Admin::Users::UsersController
> >>
> >> active_scaffold :admin do |conf|
> >>
> >> conf.list.mark_records = true
> >>
> >> end
> >>
> >> end
> >>
> >> Nothing happens (even after server restart). No checkboxes displaying.
> >>
> >> Well, add next part of code:
> >> before_filter :blah
> >>
> >> def blah
> >>
> >> self.class.send :include, ActiveScaffold::Actions::Mark
> >> active_scaffold_config.list.mark_records = true
> >>
> >> end
> >>
> >> Again, nothing. If I'll put debugger into that method - I'll be able to
> >> read the marked_records set and add items to it (and read'em back on next
> >> request).
> >> Well, in the
> >> source<https://github.com/activescaffold/active_scaffold/blob/master/lib
> >> /active_scaffold/config/mark.rb>I've found the :marked column, try to add
> >> it:
> >>
> >> class Admin::Users::AdminsController < Admin::Users::UsersController
> >>
> >> active_scaffold :admin do |conf|
> >>
> >> conf.list.mark_records = true
> >>
> >> end
> >> before_filter :blah
> >>
> >> def blah
> >>
> >> self.class.send :include, ActiveScaffold::Actions::Mark
> >> active_scaffold_config.list.mark_records = true
> >> active_scaffold_config.list.columns << :marked
> >>
> >> end
> >>
> >> end
> >>
> >> And after that on the next request I've got the fatality:
> >>
> >> RuntimeError in Admin/users/admins#index
> >>
> >> Showing *
> >> /home/envek/.rvm/gems/ruby-1.9.3-p125/bundler/gems/active_scaffold-6fa914
> >> 6cbd52/frontends/default/views/_list_column_headings.html.erb * where
> >> line *#9* raised:

Andrey Novikov

unread,
Jun 15, 2012, 12:50:12 AM6/15/12
to actives...@googlegroups.com
Sergio, thanks a lot!

But there is a problem in russian localization - error thrown if select 2 or more records, I've created pull request on github with fix. Other AS localizations seems to work well.

четверг, 14 июня 2012 г., 1:34:57 UTC+10 пользователь Sergio Cambra написал:

Sergio Cambra

unread,
Jun 15, 2012, 2:54:53 AM6/15/12
to actives...@googlegroups.com
Thanks

Nick Rogers

unread,
Jun 15, 2012, 12:09:57 PM6/15/12
to actives...@googlegroups.com
I think these changes have broken the active_scaffold_batch plugin. I no longer see the "Marked" destroy option, and Marked update no longer works.

I'm using this plugin:

This worked in active_scaffold 3.2.11

--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to actives...@googlegroups.com.
To unsubscribe from this group, send email to activescaffol...@googlegroups.com.

Sergio Cambra

unread,
Jun 19, 2012, 6:03:10 AM6/19/12
to actives...@googlegroups.com
It's working here with active_scaffold_batch's master branch. Have you added
:mark action to the controller? You won't get marked destroy option if you
don't add mark action.

Sergio Cambra

unread,
Jun 19, 2012, 6:45:44 AM6/19/12
to actives...@googlegroups.com
You were right, I was testing with 3.2.12 but with master fails. I have
updated active_scaffold_batch so it work with active_scaffold's master branch

Nick Rogers

unread,
Jun 19, 2012, 10:48:05 AM6/19/12
to actives...@googlegroups.com
Works now. Thanks!
Reply all
Reply to author
Forward
0 new messages