Ruby on Rails : rails generate controller does not work
rails generate resource
rails generate model example
rails generate scaffold not working
rails generate controller and view
rails g controller api
rails scaffold controller
I am new to ruby and rails and I am having a problem with generating controllers.
Some context :
$ rails -v Rails 4.1.1
App is created correctly :
$ rails new test_app create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app [...] Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. run bundle exec spring binstub --all * bin/rake: spring inserted * bin/rails: spring inserted
Server runs fine :
$ rails server => Booting WEBrick => Rails 4.1.1 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server [2014-06-07 11:12:20] INFO WEBrick 1.3.1 [2014-06-07 11:12:20] INFO ruby 1.9.3 (2014-02-24) [x86_64-cygwin] [2014-06-07 11:12:20] INFO WEBrick::HTTPServer#start: pid=3340 port=3000
I can browse the default page, but then when I try to go to the next step, it's failing :
$ rails generate controller welcome index
Nothing happens and the files are not generated. There is not output at all so I don't know where I should look to fix the issue.
I already tried creating a fresh new app and reinstalling rails, but this doesn't help.
Try to run
rails generate may not work because spring is already running.
Rails is not generating new controller, Try using bundle exec rails g controller Welcome index. Using bundle exec will lock all calls to the specific gem's you've specified in the Gemfile instead of the This functionality will be achieved by the following lines of code. Edit the following lines in book_controller.rb file. def list @books = Book.all end. The @books = Book.all line in the list method tells Rails to search the books table and store each row it finds in the @books instance object.
I had the same problem on my Windows machine while trying to run
rails generate controller Users new.
First, make sure your spring is not running. Stop it with
If it did not help THEN:
- Go to your Gemfile and comment out next two lines :
gem 'spring' and gem 'spring-watcher-listen', '~> 2.0.0'
- In your terminal, run:
"rails generate controller" not working, This generates a skeletal Rails installation in ~/Code/Ruby/ weblog. I assume this is a problem with rails not finding generate.rb . ==== My ruby-on-rails I am getting date and time from datetime picker and I want to store this into database. Database field type= datetime. I am using ruby on rails. If statement for search field in Rails jquery,ruby-on-rails,search,if-statement I have a blog site and recently added a search bar for visitors to browse through blog posts. When used
spring stop and it said that it was not running.
Then I did a
bundle install and now it worked..
Command "rails generate model" does not work in one particular , In a project, which uses Rails 4.2.5 and Ruby 2.3, when I run rails Command "rails generate model" does not work in one particular project #23446 a controller, not the ones that are related to a model (also rspec does not 1.3 rails generate. The rails generate command uses templates to create a whole lot of things. Running rails generate by itself gives a list of available generators: You can also use the alias “g” to invoke the generator command: rails g.
I am using rails 6 and also worked for me.
Rails g not working · Issue #51 · parasew/instiki · GitHub, I'm not sure if this is a legitimate issue or more of a local one, but I'm Rails generate doesn't work at all, for neither models nor controllers. and find an alternate way of writing it (and i'm using Rails 4.2.6. and Ruby 2.3 btw). The Rails Command LineAfter reading this guide, you will know: How to create a Rails application. How to generate models, controllers, database migrations, and unit tests. How to start a development server. How to experiment with objects through an interactive shell.
Make sure you are in the correct folder and not the environment, e.g.
I got the error and I had forgotten to
The 'spring' and 'spring-watcher-listen' gems are still installed.
The Rails Command Line, How to generate models, controllers, database migrations, and unit tests. How to start a With no further work, rails server will run our new shiny Rails app: Upgrading Ruby on RailsThis guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails. These steps are also available in individual release guides.
Pages controller doesn't appear after being generated, Maybe you have a syntax error, or a typo. Hide error. /home/ccuser/.gem/ruby/2.3.0/gems/activesupport-4.1.1/lib/active_support/ Rails for API only applications. Contribute to rails-api/rails-api development by creating an account on GitHub.
[reported #125, #128] 'rails generate controller Pages' isn't working , When on the create controller task I enter the command and it doesn't bring me back to the I can't get > rails generate controller Pages to work. Upgrade to at least Rubygems 2.1.0 and run gem pristine --all for better startup performance ". As an example, if a user goes to /clients/new in your application to add a new client, Rails will create an instance of ClientsController and call its new method. Note that the empty method from the example above would work just fine because Rails will by default render the new.html.erb view unless the action says otherwise.
Problems with 'generate' command., While on RubyMine 2018.3's consolle the command works. Is there someone that can help me understand what's not working on the terminal? you can try "rails generate scaffold posts" then you will create posts model Rails was created in 2003 by David Heinemeier Hansson, while working on the code base for Basecamp, a project management tool, by 37signals. David extracted Ruby on Rails and officially released it as open source code in July of 2004. Despite rapid iteration of the Rails code base throughout the years, it has stuck to three basic principles:
- did you write that command in a separate tab or in the same tab but after closing the server?
- As I am seeing the
$symbol before the
rails gene..command, I didn't guess about the mistake. But it can be ......
- Do you have ActiveRecord enabled? Or maybe you have a custom generator called 'controller' created by accident?
- @StefanHagen How to check if it is enabled or not ?
- Yes it is a separate tab in the app folder. The $ is just the cygwin command prompt. I have seen people having a problem with custom generator, but I have no clue how I can see if I have one. (sorry for the half reply, pressing enter sends the reply right away :-/)
- My surprise violated the principle of least surprise. I was having a good time following the guide here. I thought I would practice some more by deleting my project directory and start over when
bin/rails generate controller welcome indexresulted in no output and no file controller generation. That led me to this post.
spring stopfixed the issue. Now I have to google
spring stopso this will no longer surprise me.