How to run ruby on rails application in RubyMine IDE - ruby-on-rails

In python/flask, file app.py can be called from an IDE or the console to run an entire web application.
In Ruby on Rails, I use bin/rails server in the console to start a server to run the rails app, but I am having a hard time doing the same in RubyMine IDE. I tried running application_controller.rb file, but nothing happened.
Which file should I run in IDE to start the server and see the web app in action?

To run a Rails server from the reference Ruby Mine Doc
Press Shift+Alt+F10, and choose the desired Rails run/debug
configuration type.
If necessary, change the run/debug configuration settings. To do
that, choose Edit configurations... in the Run popup menu, and
choose the desired Rails configuration type. Rails run/debug
configuration dialog box appears.
In this dialog box, modify the desired settings. For example,
RubyMine suggests WEBrick as the default Rails server. You can
select a different server from the list of supported servers.
Click the I> button on the main toolbar.

Related

After installing tailwindcss for ruby should I skip the following suggestions/warnings:

I tried to complete the first suggestion by typing
ruby
rails bin/dev
but I was not able to get an output (The terminal showed no output )
then I realized my code was wrong so I tried once again and typed:
rails create bin/dev
But it showed me an error and said "rails aborted!
Don't know how to build task 'create' (See the list of available tasks with rails --tasks)
Did you mean? db:create"
Then I tried the other command by typing rails in front of it but that didn't work either.
So even though my app works should I bother to solve this warning or skip past it?
TLDR: You need to build your CSS output on every Tailwind style addition so execute bin/dev in a terminal to start your rails server AND watch for tailwind changes.
Hey! Your screenshot is saying that you have successfully installed Tailwind via the tailwind-rails gem.
The end of the message provides instructions on how to build your Tailwind CSS during local development so that Tailwind styles are output to the CSS and applied to your app on localhost:3000 immediately.
Option 1: (documented in the installation output) In your terminal, execute bin/dev to start your rails server AND watch for tailwind changes. This command uses a library called foreman to run two processes, reading from the Procfile.dev that was created in your project's root directory during tailwind installation.
Option 2: (documented in this section of the README) In your terminal, execute rails s in one terminal window and rails tailwindcss:watch in a different window (separate commands)
Option 1 is simpler and probably recommended.
(Based on your screenshot, you are not on a Mac and your exact command may differ, but these work for me on a macbookpro.)

Torquebox - project is not updated

I have installed:
Ubuntu 12.10
jruby 1.7.3
ruby 2
rails 3.2.13
RubyMine 5
DB2 C-Express
I have create a sample application and connected it correctly to the database - I know this because I have successfully executed the scaffold and migrate commands and check that the tables are created.
Then I have run the following commands in order to deploy my application with torquebox 2.0:
torquebox deploy
torquebox run
I have run these commands in my project folder and as a result on localhost:8080 I am seeing rails start page. I have the following issues:
Clicking on "About your application’s environment" tab I am getting the following error:
javax.servlet.ServletException: org.jruby.exceptions.RaiseException:
(NameError) cannot link Java class com.ibm.db2.jcc.DB2Driver, probable
missing dependency: Could not initialize class
com.ibm.db2.jcc.DB2Driver
org.torquebox.web.servlet.RackFilter.doRack(RackFilter.java:117)
org.torquebox.web.servlet.RackFilter.doFilter(RackFilter.java:101)
org.torquebox.web.servlet.RackFilter.doFilter(RackFilter.java:72)
org.torquebox.web.servlet.SendfileFilter.doFilter(SendfileFilter.java:49)
org.torquebox.web.servlet.SendfileFilter.doFilter(SendfileFilter.java:33)
I believe this is because the torque box is not able to find the driver. But why as it is vissible in my rails application and I successfully created/migrate tables from it using the terminal? Should I put the driver somewhere else,too?
Then I the torque box documentation is said:
Changes to your Rails application show up immediately in the browser,
as expected. When you're done, press CTRL+C in the terminal to stop
TorqueBox before continuing with the next steps.
But that's exactly what I have had to do in order to refresh the content of the page. I have changed my gem file and database.yml file but refreshing the page did not reflect this. After I have stop the server and start it again it shows something different.
Could you advise or tell me what I am doing wrong?
Without restarting the Torquebox server your can redeploy the knob with touch just run
touch $TORQUEBOX_HOME/jboss/standalone/deployments/your_apps-knob.yml.deployed
this way you don't have to restart whole JBOSS server.Deployment via descriptor
For production setups you can use Capistrano Torquebox Capistrano support

How To:Debugging Rails 3.1.x app(Ruby 1.9.3) on Aptana Studio3 in Ubuntu

Is rails debugging supported on Aptana Studio 3. I have earlier debugged Rails applications on Aptana Studio2 with the embedded browser and embedded servers.
1)How to start rails application in Debug Mode?
2)How to enable remote debugging in firefox?
My work environment is as follows and I have been using RVM
Rails 3.1.x
Ruby 1.9.3
Ubuntu 10.10
I have already installed the debug related gems
ruby-debug-base19 (0.11.25)
ruby-debug-ide19 (0.4.12)
Try removing (commenting out) ruby-debug-base19 from Gemfile. "ruby-debug-ide" should be enough, judging from the comments from a post on different IDE - RubyMine.
For debugging, right click on the project and select "Server Debug", then open the site manually in firefox (you will see the address/port the server listening to in the console). I did not manage to set a breakpoint this way, but I only had a test project with no logic in it, so I am not sure how well it works on a real project.
Not sure about your question on "remote debugging with Firefox".
Answer for Q1: Aptana is just an IDE which provides you a not bad interface to input code. I don't think it a very good idea to 'DEBUG' in it.
For me, debugging rails depends on : command line, unit tets and log files. you should first of all, write an failed unit test, then run it in the command line, and write the implementation code, then run unit test, then write implementation code ... sometimes you need to check the output/log file, finally , the unit tests bar turns to green and your code is implemented.
hope this post useful to you:
How to configure aptana for instant running of my script
Answer for Q2: I don't know your "remote debugging in firefox". If you want to show detailed error message to someone else, just start your server as "development" mode. e.g.
rails s -p 3000 -e development
or just:
rails s

How Can I Load localhost:3000 in Chrome On Issuing A "rails s" Command?

My workflow looks like this:
$>mate .
Edit stuff using textmate
Go to command line to run $>rails s
Go to Chrome to click a bookmark that loads localhost:3000
View the app
Load text mate to fix/revise
Back to command line to git
Repeat
Is it possible to rig step 3 so that it will also load a new tab with localhost:3000 in it? One less click, saved many times.
Since you're using TextMate I'll assume you're on a Mac.
Two things you can do.
Setup Phusion Passenger on Apache (Mac OS X already has apache) so you save yourself the rails s. You can find tutorials on this at many location. But basically you follow the instructions from the Passenger website and then install the Passenger PreferencePane to make your life easier. To do this you'll need the XCode installed.
Start the rails server in the background then calling open to open the URL
#!/bin/bash
#
# save this in script/start.sh
# don't forget to do chmod +x script/start.sh
rails s &
sleep 4
open http://localhost:3000
In addition to the recommendation for Passenger above, I'd also add that you can install the "Passenger Pref Pane" that will let you easily add projects and set their environments (production/development).
Passenger + Passenger Pref Pane will completely eliminate the need for rails -s, with minimal fussing on the Apache config files.
I think Textmate also allows you to do some scripting that might even get you to be able to launch and open the url in Chrome on save, but I haven't ventured into that area of Textmate yet, and it would probably take more work than just hitting refresh after the save.
If you don't mind adding some code, you could put this in your config/application.rb:
config.after_initialize do
if Rails.env == 'development'
system('open /Applications/Google\ Chrome.app http://localhost:3000')
end
end
That will open a new tab each time though and if this is a multi-person project, you may get complaints.
Another option would be to look at live-reload to get the tab to refresh when a file changes. Even without Passenger, on Rails 3 I rarely have to restart the server, so just reloading the tab might make more sense.

Rails console in Netbeans

Netbeans ide has rails console? I use Netbeans for PHP for a long time, and now I want use to my Rails applications. I saw the generators, bundle has a fast gui menu, but can I use this commands myself in Netbeans, so I looking a built in console.
right-click on the project in ur Project window, u will see a selection called "Rails Console"
-edit-
if you want shell, terminal. you might have to launch it will cmd, ssh or whatever way to access it.
--edit 2--
you might can check this out:
http://wiki.netbeans.org/FaqRubyTerminalEmulator

Resources