Install sqlite3 for Ruby on Rails - ruby-on-rails

I am starting to build Ruby on Rails project, but can't start the server, because sqlite3 is not installed
`require': cannot load such file -- sqlite3/sqlite3_native (LoadError).
I downloaded Precompiled Binaries for Windows archive from the sqlite site, where do I save the files now? What should I type in the terminal window?

To use sqlite3,
Unpack the precompiled Binaries for Windows in C:\WINDOWS\system32 folder.
Then on your cmd, do a "gem install sqlite3".
[That should fix it. To test:]
Create a rails app. "rails new test"
cd into the directory and "rails g scaffold post title:string body:text"
"rails db:migrate"

So the only way i got to install sqlite3 is by running RailsInstaller (http://railsinstaller.org/en). It installs the whole bundle of programs for Ruby on Rails app though.

Related

Impossible to execute rails s | railties-5.2.3/exe/rails (LoadError)

I can't launch my server with the command rails s, I have to use the command bundle exec rails s, but I prefer use the command rails s
Error when I launch the command rails s
Traceback (most recent call last):
1: from /home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `<main>'
/home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `load': cannot load such file -- /home/leopaul/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/exe/rails (LoadError)
My rails version is :
Rails 5.1.6.2
I think you have multiple Rails versions installed in your machine.
Sometimes when you install a gem it comes with an executable/binary as well. Examples of these include: rails, rake, rspec, pry, etc. However, when you have multiple versions of a gem installed you then will have multiple versions of these executables sitting around. So if you want to execute one of these binaries for a given rails app you may need to disambiguate which executable you want -- the one for rake v10.1 or the one for rake v10.2, for example.
So for most commands you'll want to run bundle exec to make sure you're running the right version for your project (and also to make sure that all dependencies are also loaded from the correct versions specified in your Gemfile.lock).
So answering to your question if you are able to do bundle exec rails s and unable to do rails s try reinstalling rails gem to your local machine.
gem install rails
then check current version by rails -v
I would just like to add that in my case rubygems wasn't installed.
Running sudo apt-get install rubygems solved the issue!
See docs: http://railsapps.github.io/updating-rails.html
It seems that you have installed globally is rails 4 or some other rails version and it's the reason "it doesn't execute rails s" like you say because it consider default(global rails version) rails. When you run bundle exec then it uses the rails commands from the current Gemfile, since you have rails 5 in your Gemfile then it works properly.
Also try to create gemsets for every project.
In case your case, try this:
bundle update
then excecute
rails s
Hope it will work :)

How to run a Ruby project

First of all I am not Ruby developer, hence my hopefully really simple question.
I inherited a project with the following folder structure:
Capfile
Gemfile
Rakefile
app
config.ru
config
db
doc
lib
public
script
spec
vendor
My question is:
how to run this project in local environment? I'm running MAC OS X and have Ruby and Apache installed
from the folder structure, are you able to identify framework/frameworks this project is utilising?
Thanks for you help!
Marcin
Maybe it's a Ruby on Rails project. Try these lines in the console in the project folder:
gem install bundler
bundle
rake db:create && rake db:migrate
rails s
These commands will start Rails server at localhost:3000. This project requires DB to be installed. (DB type depends on Gemfile content). Also you should check if config/database.yml file is present.
Old question, but I would open up the Gemfile and see which framework is being used. It is often the first gem in the list.

Error with Rails Edge/4 `require': cannot load such file -- thread_safe

Following ths instructions here for getting an app running off Rails Edge to test Rails 4:
What is the best way to generate a Rails app using edge?
and
How to create Edge rails application?
But running into this error:
`require': cannot load such file -- thread_safe (LoadError)
Using the command:
rails new Edge --edge --skip-bundle --database=postgresql --skip-test-unit --skip-index-html
A checkout of Rails master bin dir is on my path.
I am using rbenv with ruby 1.9.3p327.
I have cleared all my installed gems out, just running bundler.
Rails 3.2.9 works fine on my system, have an app in active development.
Issue is not having the rails gems installed (when installing via rubygems, dependencies are automatically resolved.
See https://github.com/rails/rails/pull/8589
Need to go into the cloned rails dir and run "bundle install", which will pull in the necessary gems.

install ruby on rails on windows

I need to run an application built in ruby on rails. I have installed ruby 1.9.2, rails 3.2.1, gem 1.8.15, Netbeans 6.8, glassfish v3, jdk6u30 and mysql but still, I can't get it run.
How do I install ruby on rails on WindowsXP?
I have to code on Windows at work and deploy to Linux and this is what I use
Ruby installer
Ruby Dev Kit
Install Rubygems
Open a Ruby command prompt for the next steps
gem install bundler
bundle install mysql
bundle install rails
Go to the directory you want to house your rails apps (e.g. cd \rails_source)
rails new (inserting the app name you want)
Once that is done, cd into the directory
Edit Gemfile to ask for gem 'mysql'
cd Config
edit Database.yaml to look for mysql db
cd ..
create a db for your mysql instance called _development
Go back to rails command line
bundle exec rails g scaffold (like blog_entry)
bundle exec rake db:migrate
bundle exec rake routes
Look for your desired route in the output
bundle exec rails s
Open a browser
Go to http://localhot:3000/
You should see a plain app
You can also check out Rails for Zombies which is a visual tutorial. It is not windows oriented but it helps fill in the gaps
I think its a quite simple to install ROR with mysql database on windows.
Follow the below instruction
Install Mysql Server 5.6 from [http://dev.mysql.com/downloads/mysql/] , use 32bit for XP and 64Bit for W7.
Go to mysql/bin folder under Program Files and copy and set the path in environment variable.Open command propmt and type mysql in order to check if mysql is installed correctly.
If still problem with Mysql, open run and type services.msc and check for MySQL service is started or not if not start manually.
Download ruby2.0.0, devkit 64-32 from http://rubyinstaller.org/downloads/
Download mysql connector from [http://dev.mysql.com/downloads/connector/c/] and make sure the version should be "(mysql-connector-c-noinstall-6.0.2-win32.zip)", you will find in "Looking for previous GA versions?".
Install ruby in C folder and select add path to executable while installing in first/second prompt.
Create folder devkit and extract devkit into it.
Extract mysql connector in C folder.
Open command Prompt and type ruby -v in order to check if ruby is installed, if not check ruby/bin path have to be added in environment variable.
Go to devkit folder, where you have extracted devkit, open command prompt and type ruby dk.rb init and then ruby dk.rb install.
Now we go through test, follow the instruction is given in test installation section in https://github.com/oneclick/rubyinstaller/wiki/Development-Kit and check with command starts with gem and ruby.
Create directory called dev and go inside it and type command gem install rails.
rails new app -d mysql2
Run command "bundle config build.mysql2 --no-ri --no-rdoc -- --with-mysql-dir=c:\mysql-connector[select what folder name is there for mysql connector]".
bundle install.
If still problem is exist, delete app folder and repeat command rails new app -d mysql2 again.
Go to app folder and use command rails server to start services. Check in browser with localhost:3000.
To create DB, use rake db:create in app folder.
Hope it helps.

Installing the 'responds_to_parent' plugin on Mac OS running "Snow Leopard"

I am trying to follow this tutorial to AJAXfy file uploads in my Ruby on Rails 3 application. On "Step 6. Using iframes and responds_to_parent" chapter I have to install the 'responds_to_parent' plugin but I am not able.
I use a Mac OS running "Snow Leopard", so in my Terminal I enter this:
script/plugin install http://responds-to-parent.googlecode.com/svn/trunk/
but the response is:
-bash: script/plugin: No such file or directory
What I have to enter?
BTW: "what I have to do"/"how to handle" gem and plugins for the my RoR 3 application when I will deploy it on a hosting server?
script/plugin install is no longer in rails. Use this syntax instead:
rails plugin install
All the executables inside the script directory were consolidated into script/rails with the release of Rails 3.
As far as deploying goes, using rails plugin install will add the code to your /vendor/plugins directory, so as long as you check that into your source control system, it should deploy with the rest of your code. Gems should be included in the Gemfile. You will need to use "bundle install --deployment". If you are using capistrano, there is a recipe included with bundler. More info on bundler here: http://gembundler.com/

Resources