A couple of months ago I started developing web apps with Rails. As with any new framework I use, as a step to further understanding it I’ve started to read the source code. Maybe it’s my relative recent learning of Ruby, but I’m having some troubles making sense of it.
Today I decided to look into Application.routes.draw (from routes.rb) and from the ActionDispatch::Routing documentation I found the draw method defined in rails/actionpack/lib/action_dispatch/routing/route_set.rb but I fail to see where in Application.rb (or Engine.rb or Railtie.rb) it comes into play. Additionally I don’t see where the routes method in Application is defined.
Any answer or link greatly appreciated. Thanks in advance.
Ok, I finally found the routes method in engine.rb, line #488. I’ll take it from there.
Related
Pretty new to the RoR environment and have been trying to incorporate datatables.net into my project located at here
I know where to add the css along with the cdn which is the route I'm taking but the last step for 'Initialising DataTables' and the javascript? that is has there, where would this go in ruby on rails? Spent a lot of time searching google for the answer to get a variety of solutions that didn't work and figured it was time to ask the wonderful experts here.
Finally figured out the problem. Was a simple issue where the scripts where in the body and fixing them into the head section corrected the whole thing.
I am checking the structure of the initial steps of a tutorial, to build a blog and while going through the code block by block, got to the point in which I want to read the code of ActionController::Base, but I am not able to find it, maybe some help?
Thank you.
Here it is. You won't find much there, though. Base module is quite thin. It consists almost entirely out of list of modules to include.
you can read the Rails Source Code
https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/base.rb
or the API docs
https://apidock.com/rails/ActionController/Base
Hi guys,
I have just installed blogit into my Rails 4 application. When I go to /blog I get routing error of every single route I have got. I get "undefined local variable or method". It is like that it won't load my routes at all.
Not sure if it make sense though. Please let me know what you want me to put here so you guys can have a look.
I have current_user defined in ApplicationController.
In the installation what I didn't understand is "declare which of your models acts as blogger in your app". That might be the issue.
Thanks in advance.
In case someone is looking for this.
Answer trail is in here. It is Explained fully
So just to sum it up, I added main_app to all of the links in the view and all are good.
Basically when you are in the /blog you will be in the engine, and you need to tell the app the correct path. Thanks to emaxon.
I'm trying various ways to implement pretty graphs in my app. I followed http://pullmonkey.com/projects/open_flash_chart2 steps in my app, but instead of creating test_it, I just added to my own controller. In my routes.rb, I have
resources :my_controller_name do
collection do
get 'graph_code'
end
end
also, since I don't think it could find the action my_controller_name/graph_code otherwise (I'm kind of confused as to why most tutorials leave the routes part out? Am I doing something wrong?). (I also used #graph.html_safe in my views for Rails 3)
Anyway when I go to /my_controller_name, I get the error in the flash box:
Open Flash Chart
JSON Parse Error [Syntax Error]
Error at character 0, line 1:
0: #<OpenFlashChart::OpenFlashChart:0x000001043c4b78
I don't know why this is happening. I tried creating a new app and following the guide, generating a controller named test_it. It worked (provided I corrected the routing). I can't think of how my controller is any different than test_it, except I initially generated it using a rails scaffold (so it has all the MVC parts), whereas I only generated the test_it controller. (I've also tried using/not using the json gem conflict fix, but it didn't make a difference--https://github.com/klochner/open_flash_chart/commit/00cf531387880af8c49ed5118737f0492b437f75) Thanks for any insight, I'm stumped as to why it's easy to implement on a new app but I can't add it to mine...
Thanks.
Nevermind, it seems to work if I use the old lib/base.rb instead of the json gem fix. Ah well.
Don't waste your time with Flash based charting libraries. Highcharts is definitely the way go to. It works in pretty much any browser, including those that don't support Flash. Much better performance on OS X than Flash will ever provide.
I am creating a simple facebook application using Ruby on rails and I am following the liveRail tutorial available here
http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails
The problem that Im facing is that when I launch my server it throws an error saying that it cant find the 'gem_original_require' : no such file to load facebook_rails_controller_extensions.
I have added the rfacebook gem but the error is thrown when i include the require
require "facebook_rails_controller_extensions" in the environment.rb file.
Im not completely sure whether this is the right way to go with Rails 2 but I've between making changes when i find relevant information for Rails 2
I would appreciate any suggestions on this or any links to other tutorials too.
Thank you
That tutorial is SEVERELY out-of-date and you're going to have lots of issues if you keep following it. rFacebook hasn't be actively maintained in a good 2 years. You should be using Facebooker.
There is a good facebooker tutorial here: http://apps.facebook.com/facebooker_tutorial/
Examine your $LOAD_PATH variable.
It's a common issue that your load path doesn't contain library.
Use $LOAD_PATH<<'/usr/lib/superrubylib' to add a path to load.
Uh, and it seems to be a best practice to use require File.dirname(__FILE__) + "/../relative/path" to set up relative paths.
P.S. Please, specify more data about paths and locations to let us answer your question specifically.