Search code examples
ruby-on-rails-plugins

Installing a plugin in Rails 3


I am trying to install the state_select plugin. I tried rails plugin install and rails can't find it no matter how I enter the path with require.

I tried to use bundler using gem "state_select", :git => "git://github.com/bansalakhil/state_select.git" but there is no gem for it.

Any help is appreciated!


Solution

  • Hmm. The owner of state_select claims it works on Rails 3 (http://www.railsplugins.org/plugins/293-state-select).

    I just tried it out in Rails 3 and it seems to work. The main trouble I had was installing it, because when I ran

    rails plugin install https://github.com/zdennis/state_select.git
    

    (I'm not sure if zdennis is the right one but it's just an example), I got this error:

    fatal: Couldn't find remote ref HEAD
    

    You can work around it by downloading the ZIP file and expanding it with the name "state_plugin" in vendor/plugins. Then put this in a view, without any "require" statement:

    <%= state_select(:us, {}) %>
    

    It shows a state dropdown in the view.