cannot start Rails Server, bundle install not working - ruby-on-rails

I am on Rails 4.0.0
So, I have created a new app in a new directory: rails new lpd.
I have cd' into the new lpd directory.
bundle install gives me Bundler::GemFileNotFound.
rails s does not start the server.
I cd in to another project that has a Gemfile installed, do a bundle install, that works fine and the rails server starts fine.
I cd back into my new project directory lpd and hit rails s again, no luck.
still GemFileNotFound.

There is no Gemfile in the project directory.
You can:
A. Create one yourself using a Rails 4.0 Gemfile as a template.
B. Copy one over from another Rails 4.0 project.
C. Run rails new again to recreate the project files (be careful to backup any changes you have already made such as configuration changes).

Related

Ruby on Rails - node_modules file is too big

I am trying to learn ruby on rails. I created a new project with Rails 6.1.2.1 for this purpose but it took more than 5 minutes. The problem is after creating the project, it creates a huge 100Mb+ dir which is called node_modules with every possible node_package. This does not make sense as the default behavior. Am I actually missing something?
The node_modules are for your front-end stuff. Now Ruby on Rails supports webpacker with all goodies of NodeJS. It is already in .gitignore and it is normal behavior.
When you want to save your project, you can delete this folder and whenever you need you can use yarn install to get it back.
You can create rails app without installing webpacker
--skip-webpack-install option of Rails new. It still includes the webpackergem in the Gemfile and sets up the resulting project with webpacker configuration (only rails webpacker:install is not run).

Adding ruby on rails to an existing react native app

Background
I'm developing a React Native app for the first time. I've gotten to the point where I need to start working on the back end and I'm going to use Ruby on Rails to do that. I've installed Ruby and SQLite3, and I've successfully added Ruby to my project.
Problem
As of right now, when I try to install bcrypt and jwt to the Gemfile in the project, I ran gem install bcrypt/jwt and that seemed to work, but when I try to run bundle i get an error: "Could not locate Gemfile". I am certain the Gemfile is in the directory I'm running the commands in, as I can see it in VS Code and also going down the path in C:/, etc.
Question
Can I actually add Ruby on Rails to an existing project? What could be the cause of this issue?
Thanks a lot!
If you have created a new Rails-App via rails new myapp you can cd into this directory and call bundle install.
rails new myApp && cd myApp && bund
Please check that you are in the correct directory. If you are sure that you are in the right directory then check your current rails version with rails --version.
Make sure you are in the project directory before running bundle install. For example, after running rails new myproject, you will want to cd myproject before running bundle install.
gem install - like npm install -g, programm to fetch gems,
bundle is fetching list of gems from Gemfile in your app(current folder), like package.json (not sure about naming)
1. Can I actually add Ruby on Rails to an existing project?
Yes, sure. You have a lot of variation to do that
here link the good article how create rails-react app, then you can move your front end part to react folder in the new rails application.
you can create new rails as separated application, in folder what you want as API with option rails new your_app_name --api, then send requests from react app directly to rails app port or IP(it is harder to implement, but I think it is right solution).
2. What could be the cause of this issue?
it is possible because you do not have rails app do not exist
you do not have Gemfile in your folder.

copies a rails app to a new computer: rails command not found

I have just set up ruby and rails on a freshly installed freeBSD. It works great. I can do rails new blabla mv into blabla and do rails s and it just works.
I had an up and running rails app on another computer. I copied the repertory that contained the app to the new computer running freeBSD. However, when I mv into that repertory of the rails app and to rails server I get -bash: rails: command not found
I have tried creating a new app with the same name and let rails create all the repertories and then copy the files of the existing rails app therein but no success.
I can run rails -v and rails s from within any repertory and get correct answer, but when I move into that specific repertory I get that command not found.
You're probably using a ruby version manager I suspect (rbenv/rvm)? Check the ruby version in your Gemfile (top of the file). It probably isn't the same as the ruby version you have installed. If you're using one of the above mentioned version managers than install the correct ruby for your rails project. After that you can do a gem install bundler in the project directory and after run bundle install which will install rails and all dependencies.
Which version you are using? It happens with earlier versions. Try updating your gems and bundler. And try again. Hope it helps.
Did you try running bin/rails s? I think tha you need run bundle install too.

using github for windows can't start rails server after pulling a repo

I added some collaborators to a rails project on github. They pull down the project using github for windows but then cannot start the rails server
rails server gives them the same output as typing rails
When we do ls we get:
From the Github directory I tried chmod -R 777 sindika but it didn't work. Why can't they pull down the project and start the server?
Seems like the version of your globally installed rails gem is different from the one the project is built on, so Rails don't recognize this folder as its project. Doing bundle && bundle exec rails s should do the trick. Another way to solve this would be to uninstall the current version of the Rails gem and install the one that corresponds to your project.

Rails production deployment folder?

I noticed that when I set my Rails app to production it created a folder in my application called RAILS_ENV=production I've kinda rolled back now and not pushing to production. Am I free to delete this folder?
The "rails" command in Rails 2 creates a new app, while the same in Rails 3 runs script/... so it looks like you've installed an old version of Rails on your production server.
If it's your development machine, this can happen when you have rvm installed with different versions of rails.
I have now fixed this issue, there was a 'PATH' setting in my bundler config file that kept re-creating the folder when I updated my bundle. I removed the path declaration and now it uses the default path.

Resources