How to create a Rails 3.2.* app? - ruby-on-rails-3

Hurray! Rails 4 is here...
Now, how do I create a 3.2.13 app since
rails new my app
installs rails '4.0.0.rc1'
Also, I already have rails gem 3.2.13 installed

you should do:
gem install 'rails' -v '3.2.13'
You should use a clean gemset, if you are using rvm, you can try:
rvm gemset create <name>
rvm gemset use <name>
Now you have a clean gemset, it's time to install rails,
gem install rails -v '3.2.13'
and then create a rails app,
rails new app_name

rails _3.2.13_ new app
(I'm using rbenv)

You can call specific gem (applies to any gem as far as I know) with following syntax:
rails _3.2.13_ -v
After this, it’s matter of using bundle exec rails instead of just rails, inside the application.

Related

Bundler::GemRequireError when adding gem

When I make a new Rails project, add gem 'reactive-record', and run rails server, I get a Bundler error: There was an error while trying to load the gem 'reactive-record'. (Bundler::GemRequireError).
What gives? I have Rails 4.2.5 and Ruby 2.1.2.
Cheers!
The latest version of the generator should work very well with the help of Mitch. We collaborated together to make a generator in order to simplify greatly the installation of react.rb and reactive-record.
You should be able to get up and running by adding to your gem file :
gem 'reactive_rails_generator'
Then do a bundle install
and finally :
rails g reactrb:install --all
bundle update
Will install you reactrb, reactive-record and reactive-router.
Once installed, you can create components by doing :
rails g reactrb:component Home::Show
I worked around the problem like this:
Set rvm to use Ruby 2.2.2 and Rails 4.2.4.
Download https://codeload.github.com/catprintlabs/reactive-record/zip/master
Edited reactive-record-master/Gemfile to read:
gem 'reactive-ruby'
gem 'opal'
gem 'opal-browser'
gem 'react-rails'
cd reactive-record-master/spec/test_app
bundle install
rails server
This seemed to work.
Then, I made a new Rails 4.2.4 project. Adding only gem 'reactive-record' to the Gemfile resulted in the same error. Then I made the Gemfile read:
gem 'reactive-ruby'
gem 'opal'
gem 'opal-browser'
gem 'react-rails'
gem 'reactive-record'
And voila, rails server works!
Hope this helps someone else.

How to Generate Views for Devise in HAML

This is mine Gemfile
gem 'haml'
group :development do
gem 'hpricot'
gem 'ruby_parser'
end
I then executed the following statements in a terminal/command window:
bundle install
rails generate devise:views users -e haml
or
rails generate devise:views users -t = haml
But creating devise views in erb. how to fix this issue?
Even simpler solution.
I have erb2haml installed in the development section of my Gemfile, so I just run:
rails generate devise:views
rake haml:erb2haml
# or
rake haml:replace_erbs # outdated
Done!
I have to do this
rails generate devise:views
gem "html2haml"
bundle install
for file in app/views/devise/**/*.erb; do html2haml -e $file ${file%erb}haml && rm $file; done
and now it is perfect.
Also see the devise wiki
Have a quick look here. It gives in details explanation itself from devise documentation
How-To:-Create-Haml-and-Slim-Views
seems that the option to indicate which template engine to use is missing (version 3.0.0). An issue has been open for this. https://github.com/plataformatec/devise/issues/2455
its simply erb to haml conversion case. you may use any sort of haml converter. Like this one
http://htmltohaml.com/

Using RVM, Rails 3.0.7 is messed up after installing Rails 3.1.0 beta1

Using rvm I installed and am using Ruby 1.9.2p180.
I created a gemset called rails3tutorial and, using it, installed Rails 3.0.7, created "sample_app", then used bundle to install. Very nice.
Then I created a new gemset called rails310b1, installed Rails 3.1.0 Beta 1, created an app, and bundle install'd...but it turned out I was not actually switched to the rails310b1 gemset, and so I ended up installing to ruby-1.9.2p180's default gemset (is that #global?...). I then manually deleted all the gems that had been installed!
Then I switched to rails310b1, and bundle install'd, created an app, fired up the app -- golden.
Now I switch back to the rails3tutorial gemset, and cd to the app created using it, and I get errors when running rails commands like...
$ rails generate integration_test layout_links
/Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/bin/rails:19:in `load': no such file to load -- /Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/rails-3.1.0.beta1/bin/rails (LoadError)
from /Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/bin/rails:19:in `<main>'
It's looking for /Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/rails-3.1.0.beta1/bin/rails but why?! $PATH looks fine.
Any suggestions as to what is messed up and how to clean this up, or is it best if I wipe out all my gems/gemsets and start over?...
Thanks!
There is nice screencast with basics of RVM http://screencasts.org/episodes/how-to-use-rvm but it mostly comes to using rubies:
rvm install 1.9.3
cd ~/projects/my-app
touch Gemfile
rvm use --create --rvmrc 1.9.3#rails32
gem install bundler rails
bundle exec rails new .
bundle install
bundle exec rails generate integration_test layout_links
please note you need to prefix most of the commands with bundle exec there is my gem that should save you from this problem rubygems-bundler.
also make sure you use .rvmrc files for every project so when you switch dir in console the proper ruby environment is set, the --rvmrc switch used above will generate one for you.

sqlite3 installed location for ruby on rails

I am trying to get started with ruby on rails and whenever I try to start the server using rails server command I get the sqlite3 not found error. I tried the following:
which sqlite3
And I got the following:
/opt/local/bin/sqlite3
I am thinking that should it not be
/usr/local/bin/sqlite3
Why is it installed incorrectly on my machine? How can I fix it?
Check the output of gem list. If the sqlite gem is not in there then you need to install it.
For Rails 3 you need to add the following in your Gemfile:
gem 'sqlite'
... then run:
bundle install
For Rails 2 run:
gem install sqlite

Problems with installing mail gem for Rails 3

I'm trying to install rails 3.0.7 on Mac OSX. I'm using rvm and I've got ruby 1.9.2p180 installed.
When I run
gem install rails --version 3.0.7
It seems to work fine, until it gets to the mail gem.
Fetching: mail-2.2.17.gem (100%)
ERROR: While executing gem ... (Zlib::DataError)
invalid block type
The installer them stops and rails is not installed. How do I get around this?
Update: Since I asked this question the mail gem has been updated to 2.2.19, and this seems to have solved the problem.
I just replicated your env (MacOS, ruby 1.9.2) and rails installed fine, along with the mail gem (2.2.17).
Perhaps try again? Maybe the package that was fetched was temporarily corrupt. You can also run gem with the verbose flag to see more info:
gem install rails -V --version 3.0.7