[Rails 3.2] form_tag w :remote => true doesn't fire up the js format

607 views
Skip to first unread message

Erwin

unread,
Nov 29, 2012, 9:27:46 AM11/29/12
to rubyonra...@googlegroups.com
I have a form_tag written like this :

= form_tag search_backoffice_places_path, {:remote =>"true", :id => :searchplaceForm } do
 ..  input fields
 = submit_tag t(:search)

generated html is correct :
<form accept-charset="UTF-8" action="/en/backoffice/places/search" data-remote="true" id="searchplaceForm" method="post">
...  input fields
<input  id="searchplace" name="commit" type="submit" value="Search" />
</form>

upon submit, params  received in  backoffice/places_controller#search
{"utf8"=>"✓", "country"=>"United", "city"=>"*", "street_address"=>"*", "wording"=>"*", "commit"=>"Search", "action"=>"search", "controller"=>"backoffice/places", "locale"=>"en"}

backoffice/places_controller.rb
  respond_to :html, :js
 ..
  def search
     ... params received
    @places = Place.in_country_like(@country).in_city_like(@city)...... # @places found 1
   
    respond_to do |format|
      format.html { render :index }  
      format.js { }   <=  should render  search.js.erb BUT not ... 
    end
  end

what's could be wrong ?  thanks for feedback   ( using asset pipeline )


 



Colin Law

unread,
Nov 29, 2012, 9:59:02 AM11/29/12
to rubyonra...@googlegroups.com
Can you post the full log for the action (as in log/development.log).

Colin

Erwin

unread,
Nov 29, 2012, 11:07:50 AM11/29/12
to rubyonra...@googlegroups.com, cla...@googlemail.com
[SOLVED]  Thanks Colin for pointing me to the log .. 
( test.log.. as I am testing integration w Capybara + Selenium... =>  my eyes were looking at something else ..)

I was looking the old way .. =>  a :format js ... parameter...
in non obtrusive way , the log clearly state  "Processing... as JS"
and rendering   search.js.erb at the bottom ...
so my Selenium driver is working fine ... which was not so easy to fix when working with subdomains....


Started POST "/en/backoffice/places/search" for 127.0.0.1 at 2012-11-29 15:12:05 +0100
Processing by Backoffice::PlacesController#search as JS
  Parameters: {"utf8"=>"✓", "country"=>"United", "city"=>"*", "street_address"=>"*", "wording"=>"*", "commit"=>"Search", "locale"=>"en"}
.....
  [1m [35mSubdomain Load (0.5ms) [0m  SELECT `subdomains`.* FROM `subdomains` WHERE `subdomains`.`name` = 'www' AND `subdomains`.`locale` = 'en' LIMIT 1
  [1m [36mCACHE (0.0ms) [0m   [1mSELECT `places`.* FROM `places` INNER JOIN `geolocations` ON `geolocations`.`place_id` = `places`.`id` WHERE (geolocations.country LIKE '%United%') ORDER BY created_at DESC LIMIT 5 OFFSET 0 [0m
  [1m [35m (153.3ms) [0m  SELECT DATABASE() as db
  [1m [36mGeolocation Load (0.5ms) [0m   [1mSELECT `geolocations`.* FROM `geolocations` WHERE `geolocations`.`place_id` = 1 LIMIT 1 [0m
...
  Rendered backoffice/places/_place.html.haml (20.7ms)
  Rendered backoffice/places/_list.html.haml (199.2ms)
  Rendered backoffice/places/search.js.erb (202.7ms)
Completed 200 OK in 43689ms (Views: 5584.8ms | ActiveRecord: 8.1ms)
Reply all
Reply to author
Forward
0 new messages