I inherited a Rails application and am having quite a difficult time generating a model. Running 'rails generate model Account' pauses for a moment, but then returns me to the command prompt without the output I would normally expect from a successful operation.
Environment info:
-Rails 4.2.5
-Ruby 2.3.0p, loaded via RVM
I've spent hours trying to debug this myself and have found a few interesting things:
1.) Generating a controller works as expected, only models seem broken
2.) If I create a new Rails project I can generate models as expected
3.) I've verified that spring is not running, using "spring stop"
4.) A similar problem is mentioned in this thread by a user with my same environment. I verified I'm in the proper dir, and also tried running "bundle update" as suggested by a user, but that didn't resolve the problem.
A few other resources allude to this being a problem with RVM, but rolling back to older versions of Ruby haven't made a difference.
Any idea what I'm doing wrong here?
Try the following commands:
bundle config --delete bin
rake rails:update:bin
Was able to reach out to one of the previous developers and learned that I'm dealing with JSONClient models and that's why it isn't working for me. D'oh!
Related
I made an app with --minimal since standard rails apps are bloated and I would rather add pieces one at a time so I don't end up with unused dependencies, etc.
But when I try to add ActiveStorage, I get the following:
rails aborted!
Don't know how to build task 'active_storage:install' (See the list of available tasks
with `rails --tasks`)
Same result with rails active_storage:install:migrations and app:active_storage:install:migrations.
I have uncommented this line in application.rb:
require "active_storage/engine"
But that didn't solve it. I created another app without the --minimal flag and it works just fine for that one so I am sure I am just missing some piece of the puzzle.
Any help is appreciated!
NOTE: I am using Windows Subsystem for Linux with an Ubuntu distro. Rails 6.1.4
Must have done something wrong because it started working. I think the application.rb file didn't get saved.
I created an app on one Mac. It runs fine. I checked it into GitHub and pushed it to the remote. I then go to another mac and do git fetch origin,
followed by git reset --hard. I follow this with bundle install, then rails db:reset, and rails db:migrate. I then try to register exactly as I did on the other mac. I get:
ActionController::InvalidAuthenticityToken in Devise::RegistrationsController#create
I'm afraid I'm having a problem with moving the code between machines. They both have exactly the same version of rvm, rails, rbenv, etc. It doesn't seem like it should be this flaky. What other steps are necessary?
I realized after ready the above answer from Vishal, that my environment was not persisted in github. I realize now that I have to check out the code, then run bundle install, then rake db:create, then rake db:migrate, then finally rails s, if I got not errors in the previous. When I did this, I found I had a different rails version on the target computer than I did on the source computer.
I now use a script 'laptop' which I located at: https://github.com/monfresh/laptop.git
This works on a mac ( I use macs pretty exclusively ) and sets up the same environment on each one where it is run. After doing this, I find I can check in codes on one mac, then check them out on another, run laptop, then my rails apps work correctly.
Up until now I've been using script/runner to forward bouncebacks to eblast-bounceback#mydomain.com and eblast-bounceback#dev.mydomain.com. However it is no longer working in Rails 4.0. I also can't seem to find a good resource online to illustrate how to do it. I usually get directed to the 'whenever' gem - but that's for cron jobs, not for 'piping to programs'.
So this is essentially what I'm currently doing, but is failing:
|/home/user/rails/dev.www/script/rails runner 'EBlast.receive(STDIN.read)' -e development
How do I get this to work? I'm not on Rails 4.1, I'm on 4.0. FWIW I do not have bin/rails. The above command yields "no such file or directory".
There were actually a few things I needed to do.
The email eblast-bounce#dev.mydomain.com was considered 'unroutable'. At first I figured it was because there wasn't any MX records for the subdomain, so I added one. But then I still got the error. I had manually updated the aliases file in /etc/valiases to pipe to the program using a symlinked directory (because I was deploying with Capistrano, and the directory ends up changing after every deploy). Turns out symlinks don't work for some reason when it comes to exim routing (/home/me/rails_deployments/dev.www/current/bin/rails fails). Maybe I'm wrong about the symlinks thing but the problem went away when I used the solution below.
This problem however was solved when I eventually came to another problem (/usr/bin/env: ruby: No such file or directory). I'm using RVM to manage rubies/gems, and apparently the email forwarder didn't know what ruby was. This leads to the final solution:
(when in cPanel, "pipe to program" assumes the user home directory (/home/me/))
.rvm/wrappers/ruby-2.1.0#website/ruby /home/me/rails_deployments/dev.www/current/bin/rails runner 'EBlast.receive(STDIN.read)' -e development
Where ruby-2.1.0 is my current ruby version, and #website is the gemset used by the EBlast.receive code base.
EDIT: Spoke too soon, the command has its own set of problems...(gemfile not present). This is ludicrous.
I created a new Rails project in a directory, say Desktop (rails new project1). After that, I ran the following command:
rails server
Then, the project1 was running on localhost.
After that, I made another directory with name (project1) in another location. I copied all the files from the previous location to new location. After that, when I ran the following command:
rails server
I got the following error message:
Rails is not currently installed on this system.
But it is working in the previous directory. How do I solve this?
If you are totally new to Rails development and System administration it is rather complicated in the beginning. I recommend any kind of Rails tutorial to you for examply by Michael Hartl .
As Graeme McLean points out you somewhen understand that there is information about your environment needed to help you.
Most likely the requirements you need to be set up are not set up in the place you did copy your rails project as Pavan and Thaha kp pointed out.
I've been tasked to get a Ruby-on-Rails application working on a dev machine. We have the actual source code (after generation) on a DVD.
I've installed Ruby and Rails, and confirmed both to work. I've copied the source code into C:\Sites.
I'm completely new to the whole stack and googling has given me no help.
Update: took the equivalent of a working day spread over two days. thanks for the answer. got it done in the end. o_O
If you already have the code than fire following commands and you are ready to go
cd "your project"
bundle install
rake db:migrate
rails server
and goto http://localhost:3000