RailsCasts Pro episodes are now free!

Learn more or hide this

Arturo's Profile

GitHub User: eljago

Comments by Arturo

Avatar

One thing to mention is that in the routes file, the default version has to be the last one to be defined.
I had a problem where I added a v2 on top of v1 and made it the default like this:

routes.rb
...
namespace :api, defaults: { format: 'json' } do
  scope module: :v2, constraints: ApiConstraints.new(version: 2, default: true) do
  ...
  end
  scope module: :v1, constraints: ApiConstraints.new(version: 1) do
  ...
  end
end
...

All V1 requests would be redirected to the V2 Controllers

Avatar

yes, after you insert a new field, find the select element and call chosen on it.
In my case it was like this:

ruby
  $('form').on 'click', '.add_fields', (event) ->
    time = new Date().getTime()
    regexp = new RegExp($(this).data('id'), 'g')
    $(this).before($(this).data('fields').replace(regexp, time))
    $('fieldset.show_person_role:last .chzn-select').chosen()
    event.preventDefault()

this is my association:

ruby
<fieldset class="show_person_role">
<%= f.association :person, collection: Person.order('people.name ASC').all, :input_html => { :class => "chzn-select" } %>
</fieldset>

I add the class chzn-select which is used to find the element.

Avatar

I had the same problem. Found the solution here:

http://ubuntuforums.org/showthread.php?t=1396862

Uninstalled postgresql-common and reinstalled postgresql and libpq-dev

apt-get purge postgresql-common postgresql libpq-dev
apt-get install postgresql libpq-dev

Avatar

Great episode.
I'm new to rails and so happy I subscribed.