Recordselect form doesn't appear on Rails 3.1 (asset pipeline enabled) and Active Scaffold

160 views
Skip to first unread message

Andrey Novikov

unread,
Mar 19, 2012, 9:39:20 PM3/19/12
to actives...@googlegroups.com
I'm upgrading from Rails 3.0 to 3.1 (one step in upgrade from Rails 2)

In rails 3.0 I use these versions in Gemfile, and everything works well

gem "active_scaffold", "~> 3.0.0"
gem "recordselect", "~> 3.0.4"

I've upgraded to Rails 3.1 and have enabled asset pipeline, after that recordselect form no longer appears anywhere (e.g.: while editing record of ChargeCard model, which belongs to Discipline model, config.columns[:discipline].form_ui = :record_select is set). Current Gemfile:

gem "active_scaffold", "~> 3.1.0"
gem "recordselect"

I've tried 3.1.9 and 3.2.3 versions of recordselect, latest version from git://github.com/scambra/recordselect.git , tried 3.1 and 3.2 versions of active_scaffold and result was the same: form just doesn't appeared. Asset pupeline have load proper version of recordselect's javascript, on click on the recordselect input the query to the disciplines/browse?escape=false was sent and successfully returned with html and javascript for form. No errors appeared in developer tools javascript console. Can't understand.

https://github.com/AmurSU/taurus/tree/upgrade - the whole problem code for reference, for example app/controllers/dept_head/charge_cards_controller.rb

Nick Rogers

unread,
Mar 20, 2012, 11:20:28 PM3/20/12
to actives...@googlegroups.com
Do you know if you're using jquery or prototype? I have recordselect working successfully for me with rails 3.2.2, jquery, latest official active_scaffold, and recordselect from github.com/scambra/recordselect.

In my experience, if the form doesn't appear, its something with the javascript library or javascript not being loaded in the asset pipeline. Sounds like you've already checked that though...

--
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/-/bqAlmkCJeFAJ.
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,
Mar 21, 2012, 2:51:46 AM3/21/12
to actives...@googlegroups.com
Fixed it!

I found, that on click in recordselect field the is RecordSelect.Abstract.open function is fired (from https://github.com/scambra/recordselect/blob/master/app/assets/javascripts/jquery/record_select.js#L219), that contains ajax call with success callback, but that callback doesn't fire.

I've put the next code into developer tools console:

$.ajaxSetup({
  error: function (XMLHttpRequest, textStatus, errorThrown) { alert("Error!\n"+textStatus); }
});

And got a "parsererror" message.

Server returns answer from browse?escape=false with text/javascript mime-type and HTML-data. It caused jQuery to fail ajax-request with "parser error" reason, but source ajax call from jquery/record_select.js:222 haven't an error callback to catch that situation.

In my app assets javascripts I've found next code (added a long, long time ago for now unknown reason):

// makes Rails to know that jQuery Ajax requests should be processed as .js format
$.ajaxSetup({
    'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
});

After I've removed it and cleared the cache (dammit cache!) form is become to appear (server now returns text/html).

Thanks for attention. Sorry for my English :-)

Atastor

unread,
Mar 21, 2012, 3:10:13 AM3/21/12
to actives...@googlegroups.com
Great :-)

Thanks for sharing! This group couldn't do without.

Regards
Michael
Reply all
Reply to author
Forward
0 new messages