Rails: 3.2.6
twitter-bootstrap-rails (2.2.3, 2.1.0)
I did the following:
rails generate bootstrap:install static -s
I then generated the scaffolding for certification as follows:
rails generate scaffold certification id:integer user_id:integer name:string description:string location:string status:string --skip-stylesheets -s
Then I tried to generate the twitter bootstrap views as follows:
rails generate bootstrap:themed certifications -f -s
Which gave me the following error:
undefined method `fields' for #<Class:0x007fe5e7282060>
and no changes were made to the certifications views. Any ideas?
I had similar issues, because I was working with a mix of mongoid and active records. I guess somehow there were conflicts while using the generator and it couldn't find the fields method anymore.
The solution for me was a reinstall twitter-bootstrap-rails gem with the following:
gem "twitter-bootstrap-rails", :git => 'https://github.com/seyhunak/twitter-bootstrap-rails.git'
Also, do not forget to run
rake db:migrate
after your
rails generate scaffold ...
For those working with mongoid, additional tip: everytime I have to generate a scaffold for an active record, I comment:
#gem "mongoid", "~> 3.0"
#gem "composite_primary_keys"
Then, generate, then uncomment
Related
I'm trying to run the following command after installing the Devise gem:
Gunface:/ Jacob$ cd ~/12-in-12/Forum
Gunface:Forum Jacob$ rails g devise:views
I'm getting this error:
Could not find generator 'devise:views'. Maybe you meant 'assets', 'scss:assets' or 'js:assets'
I've run the helper, and the views generator is in fact missing:
Please choose a generator below.
Rails:
assets
controller
generator
helper
integration_test
jbuilder
job
mailer
migration
model
resource
scaffold
scaffold_controller
task
I have definitely followed the instructions that appear after installing Devise.
So, is there a way to create a views generator in a Rails app? I have no idea how to fix this, and I haven't found a similar question that helped resolve this problem.
Add the Devise gem to Gemfile, then specify the ruby version in line 2 with
ruby '2.2.2'
Save the Gemfile
Run
$ bundle install
Run
$ rails g devise:views
I am using active admin as given in Active admin install with Rails 4 . gem 'activeadmin', github: 'activeadmin' is installing.
But still i am getting error after running rails generate active_admin:install.
The error is
DEPRECATION WARNING: Support for Rails < 4.0.4 will be dropped from Formtastic 4.0. invoke devise
To use devise you need to specify it in your Gemfile. If you don't want to use devise, run the generator with --skip-users.
It means you did not install devise.
You want to
a) install devise: gem install devise, and then run rails generate active_admin:install. This will create default AdminUser object.
b) use the hint from warning, and install activeadmin with rails generate active_admin:install --skip-users.
I would be appreciated if you could help me in this problem:
I am using rails 3.2.11 and I have already installed
"gem installed scaffold"
I do not know why it is not working for me
main$ rails generate scaffold idea name:string description:text picture:string
It give me this error:
Usage: rails new APP_PATH [options]
generate command is for generating new code. scaffold is a type of generators, it is for generating models, controllers and views in existing application.
To create the project you have to use rails new APP_PATH [options].
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
This is my setup cheat sheet:
In the terminal run the following command:
rails new "app name" --database=postgresql --skip-test-unit
In the gem file add the following:
group :development, :test do
gem "rspec-rails"
gem "factory_girl_rails" `<- only put in test group, not dev`
gem "valid_attribute"
gem "shoulda-matchers"
gem "capybara"
gem "launchy"
gem "simple_form"
gem "pry-rails"
end
group :production do
gem 'rails_12factor'
end
Run ' bundle install ' to install the gems
rails generate rspec:install
rails generate simple_form:install
in spec_helper file require 'capybara/rails'
valid_attribute also needs --> require 'valid_attribute' in the spec_helper.rb file
capybara will need -> require 'spec_helper' in each of the test files in the directory /spec/features/filename_spec.rb
You should see a number of files and directories created for you. The most important of these is the spec directory.
Now you can create models: by tying the model generation process to the creation of the files and directories that RSpec wants, rspec-rails ensures that we have a testing environment that we need.
Add config/database.yml to /.gitignore file
I think you missed to get into your working folder before running the generate scaffold action.
cd "your_app" then run rails generate scaffold idea name:string description:text picture:string
I have commented out gem 'simple_form' from my Gemfile with Rails Rails 3.2.12 and Ruby 2.0.0p0. When I do rails generate scaffold, I still get simple_form forms.
Is there a way to get the original form_for scaffolds instead?
The following should remove it properly:
# rails destroy simple_form:install
# bundle
Also, you can check for files in lib/templates and remove the associated ones for simple_form.
http://railscasts.com/episodes/234-simple-form?view=comments#comment_150699
http://github.com/plataformatec/simple_form/issues/680
try after installing bundle again,
bundle install
How do I use the twitter-bootstrap-rails gem in my Rails 3.2.1 app? What is the workflow?
After I do:
rails g bootstrap:layout [LAYOUT_NAME] [*fixed or fluid] [options]
what do I do next? Do I just copy and paste the generated code into my view? Do I do this for every view? If so, how is doing
rails g bootstrap:themed [RESOURCE_NAME] [LAYOUT] [options]
any different?
Do you guys even use the rails generators?
Thanks
I'm the author of twitter-bootstrap-rails gem. I'll give you a quick walktrough to how to install and use twitter-bootstrap-rails.
Ruby stack;
(Ruby 1.9.3, Rails 3.1 or Rails 3.2 is required. Use RVM to get started)
After bundling gem to Gemfile by;
gem 'twitter-bootstrap-rails'
bundle install
Run install generator
rails g bootstrap:install
(it will includes Twitter Bootstrap to your app's asset pipeline)
Run layout generator
rails g bootstrap:layout application fixed
(it will generates layout for you, by default application.html.erb and fixed layout will generates)
Run themed generator (optional);
rails g scaffold post title:string description:text
(this step uses Rails generators to create CRUD stuff for you)
rake db:migrate
(migrating to database)
rails g bootstrap:themed posts
(Twitter Bootstrap compatible styling for your 'posts' views and form)
Also there is detailed documentation to install, usage and generators, coffeescript etc.
https://github.com/seyhunak/twitter-bootstrap-rails.
There is a RailsCasts tutorial that is a great starting point:
http://railscasts.com/episodes/328-twitter-bootstrap-basics
Run:
rails new APPLICATION -m anyfile.rb
anyfile.rb
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
generate("scaffold", "Post title:string content:text")
rake("db:create")
rake("db:migrate")
generate("bootstrap:layout", "application fluid")
generate("bootstrap:install")
generate("bootstrap:themed", "posts")
git :init
git :add => "."
git :commit => "-m First commit!"