Rails webpacker:uninstall? - ruby-on-rails

I installed stimulus into my Rails 6 app using rails webpacker:install:stimulus, but then decided I don't need it. What is the command to uninstall something that was installed via webpacker? I tried rails webpacker:uninstall:stimulus but that didn't work, and googling only led me to people asking how to uninstall webpacker itself.

The webpacker:install:stimulus task does three things:
Adds stimulus to the dependencies in package.json
Creates app/javascript/controllers (plus a couple of sample files)
Adds import "controllers" to the bottom of app/javascript/application.js
So, presumably removing those three things will suffice to uninstall.

Related

How do you configure Webpacker to work with a Rails engine?

I'm trying to configure Webpacker to work with a Rails engine. I'm specifically interested in how people are setting up their webpacker.yml to move their engine's assets to the main app's /public/ folder.
First, I've followed the Webpacker instructions for Using in Rails Engines. However, Step 7 stumps me. The idea here is to set the public_root_path to your app's /public folder. I could obviously hard-code the correct path on my personal machine, but that's unsustainable for production or other devs. I can't rely on ERB to have a dynamic path either.
I also tried the second option of Step 7 which involves middleware, but it didn't seem to have any effect.
I ultimately want to be able to import JavaScript from the engine into the main app from the app/javascript/packs/application.js file. How do I get Webpacker to find the files from the engine without hard-coding the path?

How can I use bootstrap in react with rails

I have tried using npm package reactstrap.
My components:
import { Col, Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap';
I'm getting the following error:
ExecJS::ProgramError at /dir/xyz
TypeError: require is not a function
The webpacker-gem is the way to go for react + rails, not sprockets, which is ok for jQuery style JS, but not for complicated ES6-based stacks.
From the README:
To use Webpacker with React, create a new Rails 5.1+ app using --webpack=react option:
# Rails 5.1+
rails new myapp --webpack=react
(or run bundle exec rails webpacker:install:react in a existing Rails app already setup with Webpacker).
The installer will add all relevant dependencies using Yarn, changes to the configuration files, and an example React component to your project in app/javascript/packs so that you can experiment with React right away.
Note that you'll be using yarn from then on, instead of npm.

How do I set up an old Ruby on Rails project on a new server?

I'm not a RoR programmer myself, but a good client of ours has sent a project their previous web team built and I need to get it up and running on their server.
The server uses cPanel and Ruby on Rails is already installed. I've created a project via the cPanel wizard and located the file tree via SSH.
Using SSH, I've tried to replace this file tree with the project I've been sent, but when I hit 'run' in cPanel, the application doesn't actually start (although the success message would indicate that it has).
If I leave the original cPanel-created application in place, I can run/stop no problem and the web interface at :12001 opens up just fine.
I assume there are either conflicts with RoR versions that I need to resolve, or there's simply more to it than just replacing the file tree? Again I'm not a RoR programmer and I'm having a hard time finding a migration guide that tells me anything other than "set up in cPanel and replace the files".
I'd very much appreciate either some genuinely useful links to RoR application setup/migration guides (ideally for cPanel) or a step-by-step answer please.
First, forget Cpanel for now. Try in one environment where you can control everything.
Try to know better the rails version used and the associated gem19s or plugin if from 2.x days. The ruby version is important too, only then you can start defining a plan.
I'm afraid you won't get a step-by-step answer, but I'm sure you can be pointed in the right direction by providing the requested information.
Simple questions: Do you have a Gemfile file at the top at your project? Do you have any plugins (stuff in vendor/plugins)?
Update:
With the Gemfile provided here are the required steps:
Install ruby (if you haven't install it using rvm. The version 1.9.3-x should be the safest.
Install rubygems
Install bundler
Go the project dir and run bundle install
run rake db:migrate (assure you have the database setup acording to config/database.yml
run rails s and check the logs and see if the server is up.
If after installing bundler, you don't have the bundle command in your path, you need to add this your .bash_profile:
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH

Grab Ruby on Rails files and install on local machine

general question that can be used in many different situations, so I thought it would be interesting to ask.
I'm semi new to Ruby and am learning from Treehouse. I am doing the social media site project, and am about half way through.
I was hoping to set up a separate installation from the source files they give you, of the completed site, to do a simple compare and contrast, and really I am just curious as to what the final product is gonna be like.
My question is, is there an easy way to just grab their files, install all the gems and dependencies and run the rails server. If I just try to run the server on the folder, I get a bunch of errors about Gems not being installed and such, which is expected.
If anyone has a process they use when doing things like migrated entire environments from one location to another, it would be appreciated!
Go to project directory.
Install all of the required Gems by executing
bundle install
Create database by executing
rake db:create
Then migrate the database by executing
rake db:migrate
And finally run the application using
rails s
If you have cloned their repository, or copied the files to a folder, try running
bundle install
from the command line

How to get a rails 2.3.3 application running on Bluehost with fastcgi

Using Your Ruby Gem(s)
You will need to add /home/username/ruby/gems to the include path.
You can do this by **adding the following code to your script**:
$:.push("/home/username/ruby/gems")
What script are they referring to? This is vague... Where do I add directories to the ruby include path?
Got it. Looks like the gem path for a default bluehost install requires some "massaging" to work. :) Following instructions from here resolved the problem for me (relevant parts cut and pasted below as well):
http://www.bluehosttricks.com
A) You will need to have the ability to install gems locally. You can do this by following these directions (via SSH):
1) Add the following lines to your $HOME/.bashrc file (these can be copy and pasted):
export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HOME/ruby/gems/bin
2) Now modify the applications environment.rb file so that the correct gem path is included. This line should go up at the top before the version of rails is specified:
ENV['GEM_PATH'] = '/path/to/their/home/ruby/gems:/usr/lib/ruby/gems/1.8'
3) Kill off any fastcgi processes that they might have running and the issue should be fixed.
EDIT:
I ended up having to follow ALL the steps in the tutorial I linked above. You have to manually edit the rack fastcgi handler file or else the dispatcher will complain. Apparently this is specific to Rails 2.3.3 (2.3.2 worked fine on BH (allegedly)).

Resources