Ask A Question

Notifications

You’re not receiving notifications from this thread.

Problems with 'generate' command.

squirrool asked in Rails

Hello everyone,
as you read in the title I have an issue with the 'generate' command from the terminal.
following you will find pasted the command i am giving:

MacBooks-MacBook-Pro:squirrool giovanni$ rails generate controller posts index
Running via Spring preloader in process 45137
      create  app/controllers/posts_controller.rb
       route  get 'posts/index'
      invoke  erb
      create    app/views/posts
      create    app/views/posts/index.html.erb
      invoke  test_unit
      create    test/controllers/posts_controller_test.rb
      invoke  helper
      create    app/helpers/posts_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/posts.coffee
      invoke    scss
      create      app/assets/stylesheets/posts.scss

The commands looks like it's working but actually it doesn't create files in views controllers and it doesn't add any line at routes.rb.

While on RubyMine 2018.3's consolle the command works.
I use ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
Rails 5.2.2 on MacOs Mojave

Is there someone that can help me understand what's not working on the terminal?
I don't want to do everything on RubyMine.
Thank you,
Giovanni

Reply

what do you want squirrool

if you wanna create controller for views/posts/index.html.erb file you can try "rails generate controller posts"
if you wanna create posts page with some data (user id, user name, user email etc.) you can try "rails generate scaffold posts" then you will create posts model , controller and routes
e.g "rails generate scaffold posts user_id:integer username:string email:string price:decimal update_at:datetime"

Reply

squirrool seems odd due to the output in the terminal. Question - is MacBooks-MacBook-Pro:squirrool giovanni$ your root folder? or the project folder?
You obviously created the controller, route and view.

Reply

1.'Squirrol' is the name of my project folder.
The commans seems to answer properly but all the files he tells me he created, don't actually exist.
Is it possible that RubyMine blocks the commands that the terminal has done?

  1. I also tried to open a new project and all the commands answer properly. The point is i didn't use RubyMine but Sublime: no matter this I tried to cancel the Squirrool project from RubyMine and with the rm -dR squirrool Command, but if i open it again I still have the same problem. While the Squirrool-Test Project that i have never opened through RubyMine works perfectly and fulfills the commands from the terminal.

Thank you

Reply

It's quite possible depending on your RubyMine settings. I had a similar issue with RubyMine in the past. One thing I'd check is to see what's in the Rubymine folder or whever is saves to. See if anything from your project is in RubyMine folder or it's subfolders.
Do you want to save the Squirrol project?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.