WebStorm + webpacker debugging - ruby-on-rails

Hello StackOverflow community!
My team is working on a ruby on rails project, where some parts are written in react. We are using webpacker gem to bundle js files into packs.
I'm trying to set up WebStorm to work with our project, but I have problems with the debugger - webstorm is not hitting any breakpoints.
I'm launching rails s and ./bin/webpack-dev-server in separate terminal instances, installed chrome extension and created JavaScript Debug configuration, pointing to the view where react app resides (on the port 3000). Also added devtool: 'eval' to webpack configuration. In the chrome dev tools I see webpack:// source and I can successfully set breakpoints there.
How to configure this tooling to have breakpoints working?

normally all you need for debugging apps bundled with webpack is to make sure that sourcemaps are properly generated. The best choice here is devtool: 'source-map' (see https://webpack.js.org/configuration/devtool/). eval sourcemaps are not accurate and not too suitable for debugging (quality is "generated code" rather than "original code").
In some cases, you might also need to specify URL mappings - see https://blog.jetbrains.com/webstorm/2015/09/debugging-webpack-applications-in-webstorm/ for more info.
But there are no generic instructions that would work for each and every configuration - as you can configure webpack in dozens of ways. So I can hardly advise on exact steps unless you provide a project you are trying to debug

Related

Cannot start the debugger in Rubymine. Rails server launcher wasn't found in project

I was trying to debug a rails application(4.03) using rubymine IDE version 7.0.2, but when I configure my application like this
The IDE complained that Rails Server launcher wasn't found in the project.
Please tell me what can I do fix the issue, and could you please recommend other ways of debugging a rails application.
Please note that this bug is easily replicated using Ruby Mine by following these steps.
Create a new rails projects with Ruby Mine, for example DebuggingRails. Which will generate default folders and files. At this point one can debug the application normally.
Create a new folder let's say Server.
Copy all the generated files above to the Server folder, so the project structure will be
DebuggingRails\Server.
Create a debugging configuration , which points to the DebuggingRails\Server.
Try to debug the application using the IDE.
The message "Rails server launcher wasn't found in project" appears
Thanks.
Close your project, remove the .idea folder, and open it back up again.
I had this problem because i chose the wrong folder, you must choose the root folder in the rails project. For example i had this structure
-MyProject
---RoR
-----app
-----bin
-----condig
-----etc
Then I chose the folder call
MyProject
It was wrong.
The correct is choose the folder
RoR

How to Tell Engine Yard to Not Delete a File in the .gitignore

To give you some context, I'm trying to use Figaro to safely add in environment variables without having to worry about security risks. The problem is is that I can't seem to get Engine Yard to play nice with production.
I went and did a touch application.yml and then vim application.yml, i, and then command+v to insert that api keys and what not. I know the ENV['VARIABLES'] work because of development and all my rspec and cucumber tests (which utilize the APIs), passed.
When I've got everything ready, I add within the .gitignore:
# Ignore application configuration
/config/application.yml
Afterwards, I deploy the site. I open it up and data isn't going to the APIs anymore. OK...
cd into config and discover application.yml isn't there anymore. Paste it back in... Redeploy the site since now it understands it has to ignore that file and I'm not seeing changes on production. Check back... and its gone again!
Stumped on what's going on.
Simply putting a file into your deployed application's filesystem will not work because you get a clean environment each time you deploy. EngineYard cannot know that you want that particular file copied to that particular location without a little bit of extra work.
Their official recommendation is to put your YAML configuration files in /data/<app>/shared/config and symlink them to /data/<app>/current/config each time you deploy using deploy hooks.

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

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

RubyMine Support for SASS

I'm wondering if anyone has managed to integrate SASS into their RubyMine environment, and if so, how they managed to configure it? I'm a little confused, because although there is a SASS plugin by default in RubyMine, I don't seem to be able to use SCSS files in my project.
Presently what I do is open up a Terminal window in my SCSS directory and run the standard sass --watch source:destination command to monitor and rewrite my SCSS files to CSS. This works OK, but I'd feel a lot smarter if I could figure out how to configure the RubyMine IDE to add it as a run-able service.
My guess is that it has something to do with the Run / Edit Configurations menu, which would add it as a run-able service like Spork and Rspec, but I'm not certain what I would actually configure that to work properly (or if that's even the right way to do it).
Any thoughts?
OK, 45 minutes of experimentation later and it's all figured out. First, you need to know the EXACT command you intend on running in SASS, so if you plan to monitor multiple directories or something else using multiple arguments, test it in a command line for functionality first. Then:
Click menu Run / Edit Configurations
Click Ruby, then the little + button to create a new Ruby configuration
Fill in the dialog boxes using the following template:
Ruby Script: /Users/username/.rvm/gems/ruby-1.9.2-p180#global/bin/sass
Script Arguments: --watch sourcedir1:destinationdir1 --watch sourcedir2:destinationdir2
Working Directory: /my_rails_project/public/stylesheets
Ruby Arguments: -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
Notes: I just used the default Ruby Arguments, and I didn't put any environmental variables in. Works like a champ.

Resources