Posts tagged ruby on rails
If you’re reading this, then you’re probably aware of Twitter’s Bootstrap – an awesome way to save yourself hours of knee-deep CSS & layout hell.
Integrating this with Ruby on Rails 3.1+ is reasonably trivial (ie, stick the files in the right places) – there are plenty of other HOWTOs online so I won’t cover it here. What is more difficult however, is getting the forms to style properly, even more so when your form is reloaded with validation errors. Rails encapsulates errored inputs (and labels) with
which completely shags up any pretty layout you might have had.
Enter jamiepenney’s Form Builder for Twitter Bootstrap 2 Form Elements. Not only does it save you shedloads of HTML hackery, by reducing this:
<%= f.label :year, :class => "control-label" %>
<%= f.text_field :year, :class => "input-xlarge span1", :type => "text" %>
but it also uses Nokogiri calls to destroy and stamp viciously on all of the hideous “field_with_error” divs. Awesomes.
Hello pretty Bootstrap forms. 8=)
I’ve been hacking around with a bit of Ruby on Rails using Ubuntu Linux. Today I was stupid enough to try setting up RoR on my Windows XP box.
I can confirm that it is possible, but a right PITA! Hopefully this guide won’t need to change too much as all of the versions off downloaded apps are specific and not “get the newest one”.
- If you’re behind a web proxy, start by setting your HTTP_PROXY environment variable. It should be in a full URL format, ie SET HTTP_PROXY=http://daves-proxy.com:8080
- Download Ruby. You need version 1.8.7 (yes, I know this is an old version) as various bits won’t install using Ruby 1.9.2. Choose to add the Ruby executables to your path. If you don’t know what this means, just do it.
- Download the Ruby DevKit from this page and unpack it to a subfolder called “devkit” within your Ruby folder, so probably c:\ruby187\devkit. For some bizarre reason, some gems need this to install, so do this now to save yourself a headache later on.
- Download RubyGems. RubyGems is your package installer for Ruby, a bit like Perl’s ppk. Again, you need an old version to make everything work nicely, hence the link to version 1.6.2. Extract it, then run “ruby setup.rb”
- Now you need to install Rails – run “gem install rails”
- SQLite is great for development purposes – annoyingly you need a specific version of it to work properly (3.7.3). Download SQLite v3.7.3 here, then extract it to your Ruby bin folder, probably something like c:\ruby187\bin if you accepted the default when installing Ruby.
- Change to your development folder then type “rails new my_app”. If all is ok you’ll see it create an application skeleton.
- Change into the my_app subfolder, and type “bundle install”. This ensures you have all the gems installed for the app you’ve just created.
- Run “rails server” – this fires up the development webserver. Assuming no errors…..
- Navigate to http://localhost:3000 – if you see a congratulations page – you’re good to start developing!