I just upgraded to rails 3.2.5 and now when I generate new controllers I don't get rspec tests generated by default.
I can do rails g controller foo -t rspec, but I'd prefer to just do rails g controller foo.
How do I fix that default?
You need to do rails g rspec:install inside your project folder (presuming you have rspec in your gem file/bundle). That will activate the generators for you.
Mark of Mark's Blog has an excellent article on it here.
Related
I've installed rails using rvm. I've loaded rvm using ~/.bahsrc.
rails is working fine.
which rails
/home/user/.rvm/gems/ruby-2.1.0/bin/rails
but in that rails project folder which command says
/home/dinesh/.rvm/gems/ruby-2.0.0-p353#something/bin/rails
How's this happening? How to make my rails work in that folder?
If you are in the root of a rails project you may use
./script/rails --version # (or whatever rails command you want to call)
to be sure to use the rails version that corresponds to your project. Usually rails magic will apply inside a rails project and "happen" to find the correct version of rails, but there seems to be a number of things that can go wrong about that.
I am working on a Rails 4 app and would like to use MongoMapper and Devise for authentication. When I add devise to my Gemfile and bundle install it goes fine and I am able to rails g devise:install, and it picks up that I am using MongoMapper as my ORM. When I try to rails g mongo_mapper:config it says it cannot find the generator. Also I know that Devise supports Mongoid by default, but I like MongoMapper and would like to stick with that. I downgraded to Rails 3.2.14 and it seems to work fine. Any ideas on what I may be overlooking, or if Devise/MongoMapper support each other in Rails 4?
I got also errors using the generators to create a model for the devise user.
This worked after using:
gem 'mongo_mapper', '>= 0.13.0.beta2'
gem 'devise'
gem 'mm-devise'
and then in the devise.rb:
require 'devise/orm/mongo_mapper'
After that I did not got into any erros.
gem 'mongo_mapper'
gem 'devise'
gem 'mm-devise'
and also devise.rb should be
require 'mongo_mapper'
I am a total n00b and am trying to install Twitter-Bootstrap 3 into my rails project. The twitter-bootstrap-rails gem is unfortunately only for version 2.0, otherwise I would totally use that. Is there some kind of set up magic I need to do in my app to configure it with my Rails project other than copy and paste the Bootstrap directories into my rails project repo?
Any and all advice much appreciated!
I am a newbie to Rails 3 and Rspec. Kindly excuse my being a novice.
I am trying to use RSpec with Rails 3. I am using rails 3.0.3 and ruby 1.9.2 on ubuntu 10.04 os.
I am currently referring to the tutorial on :- http://www.railsfire.com/article/rspec-behaviour-driven-development-testing-framework. This tutorial not only uses old plugins , but old Rails version of 2.x also.
I am unable to use the old rspec generator ( rspec_scaffold ) with rspec 2.5 and rspec-rails 2.5 gem. As expected I get the following error as given below.
mohnish#mohnish-desktop:~/rails_testing/10Mar11/rspec_demo3$ rails g rspec_scaffold post title:string body:text
Could not find generator rspec_scaffold.
mohnish#mohnish-desktop:~/rails_testing/10Mar11/rspec_demo3$
Could you please tell me how should I give to accordingly for it to work for me using the above RoR configuration.
Thanks
The latest Rspec gems don't require the old generator mentioned above, basically on giving rails g in your rails app you would get all the list of generators with your app.
Thus, once you have installed the Rspec related gems, then give a rails g to your app, you need to basically run only one of the generator command from the modified list that you would get, which is rspec:install and this would be enough to get you up & running at least with a proof of concept(poc).
I'm sure this is astonishingly straightforward, and I'm just inexperienced with Rails 3, but I can't figure out how to make it work.
I'm trying to install the paper_trail plugin into my Rails 3 app; but the instructions seem designed for Rails 2. I'm running under Windows, and don't have git available.
I've tried putting gem 'paper_trail' into my Gemfile and running bundle install, which picked up the gem correctly; but rails generate paper_trail (which I assume is the new form of script/generate paper_trail fails with Could not find generator paper_trail.
Can anyone give me some step-by-step instructions to get this working?
A little late to the party. I am writing this since I found the thread through Google. Here is how I got it to work with Rail 3.0.9. I was getting the same error with
bundle exec rails generate paper_trail
as well as
bundle exec rails g paper_trail
and
rails generate paper_trail
Turns out, you need to run
bundle exec rails generate paper_trail:install
that generated the migration file for me and a
bundle exec rake db:migrate
created the table.
As of 11 October, rails generate paper_trail works as you would expect.
I've managed to make this work by simply downloading the zipped code from github, unpacking it into vendor/plugins, installing the gem (through Gemfile and bundle install), and then copy-pasting the migration code in paper_trail's generator into a blank migration of the same name.