Ruby on rails app debug and develop - ruby-on-rails

I have been in Ruby on Rails for a while. Now I clone a very nice project from GitHub and i want to debug it with RubyMines.
Can someone please sugest me how do i proceed further? Do I start with Controllers? or Models? or Route.rb file?
I want to understand the app thoroughly and develop the next version with new GUI.
Thanks.

Set your breakpoints wherever you want, in your models, controllers, or views. Then just run the debugger and go to the app in your browser. Whenever the application hits the part of the code where you set your breakpoint, it will stop and then you can go back to RubyMine and debug accordingly. It's really a fantastic feature.
Let me know if you if you're having any trouble with it.

When I am getting familiar with a rails project, I will typically set breakpoints at the controllers and step through the code as requests get to the controllers.

Related

Auto code grading system like codecademy's

I'm building a ruby on rails application with most of the views with react. I'm considering using CodeMirror as an editor for users to type in code. I want them to be able to submit the code, and the code will be run through some of my test cases and get results back, similar to how codecademy works.
What are some initial steps to achieve this?
Thank you!
Have a look at the http://reactrb.org site. There is live code editors on there. Source code for the doc site is on github.
If the code examples are in either ruby or JS you can run the test scripts in the browser (for ruby you will use opal-rspec) This makes sandboxing easy.
Sounds like a great project. If you need additional questions or help stop in at https://gitter.im/zetachang/react.rb There are a couple of people there who can help you out with the details.

How to auto restart rails server with grunt?

I am working with rails-api so each time i change controller or Route file i want to auto reload rails server, so new changes will be applied.
I got basic setup to work with this plugin: link, where rails start together with grunt.
The problem is i want to reload rails server each time any rails files are changed.
Is it possible to achieve?
Yes, of course. You will need to use Guard for this purpose. Please read carefully Guards official page. They're doing good job in explaining how to setup your development environment.
There are tutorials on RailsCasts and also on NetTuts.
Edit: I forgot to mention that there is second(but definitely not the last one) option to achieve this. If you start using Spring which is Rails application preloader. Read more about this on Github page.
Here is great tutorial on how to setup everything together - http://girders.org/blog/2014/02/06/setup-rails-41-spring-rspec-and-guard/

Rails App inside a Rails app's sub-folder

I have a rails app, but a client wants to have another rails app be hosted in a ssub-folder of the first rails app.
I can't find any help on how to do this or if it's possible, because if I go to:
http://example.com/second_app, the first app will try and route it despite another app being situated in the second_app folder.
I hope this makes sense, and someone will be able to help.
Sorry, two Rails apps with one inside the other is not possible.
If all you want is a special page for the client, you need a view, controller, and route:
$ rails g controller Pages second_page
And then change your route (config/routes.rb) from get 'pages/second_page’ to get '/second_page’.
After starting up your rails s, you can then go to localhost:3000/second_page and see your page.
If I’m completely misunderstanding what you’re trying to do, please describe your situation a bit more and I’d be happy to help.

Models not reloading in development in Rails (3.2.11) project

I've searched fairly extensively for any advice and have yet to find it so, here goes:
My Rails project fails to automatically reload models in development. Reloading them currently requires a full server restart.
Previous instances of this issue have been related to non-activerecord files placed in the models directory, though this is not the case for me.
config.cache_classes is properly set to false in my development config file. Views and controllers reload without issue.
All of my rails components are version 3.2.11. I have tried disabling all of my development-specific gems to no avail. This is obviously not a productivity stopper, but it is quite an annoyance. Any help appreciated and I am happy to provide more information if it would help, though I am not using any exotic gems.
Thanks!
Some possibilities:
You are not really running on developement environment
You are changing a model within a namespace and didn't told rails to autoload the path
You are changing a file that is included in your class, not your class directly (or any of the many variants for this)
You are caching classes
Considerations:
Things might change according to the webserver you are using
How do you know it's not reloading?
I ask my question because I was having the exact same issue when I was trying to insert a debugger into what I thought was a piece of code that was being executed. I assumed the model wasn't being reloaded since it was not hitting the debugger but it was actually a call back that was redirecting me around the code with the debugger line in it.
So, it might be something other than your models not being reloaded.

Just started a new spree app, but can't find a way to generate theme_default

Anyone know how to generate a default_theme so that it can be edited? It seems that all the core files are hidden and uneditable.
The last working spree app I made started with theme_default exposed under vendor/plugins.
Because this one is in Rails3, I pulled it right from the official railsdog git, thus no theme_default, and no haml.
I'm probably missing something obvious. Any ideas?
Basically, to create your own views, the starting point is to create our own extension. You can achieve this with the command you'll find here:
http://spreecommerce.com/documentation/extensions.html#creatingan-extension
Then it's like any raRails Engine, you can create the views you want, they'll override spree's.
Is rake sandbox what you are looking for? See Building a Sandbox Application
You only do rake sandbox just for test purpose, I have found this link
Change the command for rails g spree:extension [ext_name].

Resources