Rails Generate Controller gives me load error
The problems is the Rails 4.2.0.beta depends on the pty
gem and is unable to find it:
`require': cannot load such file -- pty
The reason is that the pty
gem is not available on Windows. Hopefully that gets fixed before Rails 4.2 is released. At the moment you can fix this problem by removing the web-console
gem from your Gemfile
:
# Gemfile
# gem 'web-console'
Run bundle install
after removing that gem.
To fix the problem that no source of timezone data could be found (TZinfo::DataSourceNotFound)
please add the following line to your Gemfile
:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
And then try again:
bundle install
bundle exec rails generate controller StaticPages home help
Rails error while trying to load a Service in a controller
Generally, this is probably a problem with where you've put your files and where Rails expect them. An in-depth guide can be found here: http://guides.rubyonrails.org/autoloading_and_reloading_constants.html.
To solve it, there are three options:
- put the module and class where Rails autoloading expects them (IMO this is the preferred solution)
- require the file where the class is defined
- add the folder where the file containing the class is located to the autoload paths
1: You need to make sure that RabbitPublisherService
and RabbitPublisher
are in a location that Rails can autoload them, for instance app/services/rabbit_publisher_service.rb
and app/services/rabbit_publisher_service/rabbit_publisher.rb
.
2: Use require
or (probably better) require_relative
.
3: Alternatively you can explicitly add the path to the autoload/eager load paths.
In my opinion, you should stick with option 1 unless you have a very good reason not to. Using Rails' defaults keeps the code to a minimum and prevents surprises for fellow developers who expect Rails defaults. Number 2 is OK as well since it's explicit. I'd definitely avoid option 3 because it sooner or later always creates a mess when you put loads of files in unexpected locations and it makes it harder for other developers who are used to Rails defaults and expect them.
Rails Generate Controller Pages Home : Helper Error
Thank you guys for all the replies, finally figured it out, like all the other SO answers, its something to do with the capitalization of file names which I just couldn't figure out, so I just wrote it directly to /c instead of ~/desktop, then in application.html.erb just changed application in lines 5 and 6 to default and it works... Wasn't missing any files or needed to do any commands or anything
rails generate command return error
It looks like you're in your home directory. To generate a rails controller you should be in the directory of the rails application you want to modify.
edit: If this isn't the case, paste what happens when you do this (from a clean directory):
rails new new-app
cd new-app
rails g controller welcome index
Related Topics
Triple Single Quote VS Triple Double Quote in Ruby
Using Passphrase Callback in Ruby Gpgme
Project Euler #3 in Ruby Solution Times Out
What's Does the [5.0] in Rails 5's Activerecord::Migration Mean
Catching Command-Line Errors Using %X
Ruby Strftime '%Z' Method Returns '0545' Instead of 'Npt'
Should I Be Using Rails or Ruby for This Website Application? How
Error: "Fatal: I Don't Handle Protocol ''Git' When Using Bundle Install
Comparing Identical Datetime Objects in Ruby -- Why Are These Two Datetime.Now's Not Equal
Get Pry to Display Characters Like [äöüßÄÖÜß] (Utf-8 Encoding)? (Possibly Windows-Specific Issue)
How to Convert PDF to Excel or CSV in Rails 4
Can't Setup Ruby Environment - Installing Fii Gem Error
Is Ruby Any Good for Gui Development
How to Call Methods Defined in Applicationcontroller in Models
Does It Matter If a Conditional Statement Comes Before or After the Expression
What Does a Single Splat/Asterisk in a Ruby Argument List Mean