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
Related
Oddly, I searched through what I think is all of the source code for "geese" thinking I would locate it but I didn't. Does anyone know?
rails/activesupport/lib/active_support/inflections.rb
Take a look at ActiveSupport::Inflector.
If you're looking for the rails code that handles inflections, it's at https://github.com/rails/rails/tree/master/activesupport/lib/active_support/inflector
If you're looking for custom pluralization in an application code, it's usually in config/initializers/inflections.rb
I've inherited a Rails 2.3 app, which lacks a solid test suite. There is a fair amount of testing, but unfortunately, many of the tests test against old, unused models, controllers, and views.
Does anyone have a solid idea of how I might go about testing which models, controllers, views, helpers, etc. are completely unused, as well as look into the ones that ARE used and see which functions specifically are not used?
You can look at this answer, and perhaps some of the other answers listed: https://stackoverflow.com/a/9788511/485864
I would probably end up logging the methods that you have, and run your code through the paths and anything not listed in the log, may be examined to see if it is indeed not used.
RCov or SimpleCov won't do this what you want?
You can try to use RubyMine, a Rails IDE, to search for unused code. Try searching for method names and stuff like that. It's been a while since I used it so I dunno if it will have a highlight on unused methods.
Also, you can try some bash commands(grep/ack/find) to search for the code snippets.
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.
Im trying to use codeigniters input class, to use the post method. Now then, I tried loading it in the controller and the autoloader but no luck! The error im getting is
Unable to load the requested file: helpers/input_helper.php
after I tried to find it by looking through my code looking for Input but the IDE couldn't find anything. I just want to essentially use
$this->input->post('varname');
nothing crazy. So, does this file not get included from codeigniter by default? I got the most recent release from github a few days ago. Im pretty new to codeigniter so if I say something stupid, please forgive me. An explanation would be very appreciated!
You should not need to load this helper at all: Input Class Docs
Note: This class is initialized automatically by the system so there
is no need to do it manually.
Try removing any of your attempts to autoload in the controller or elsewhere, then try again and see if that works.
I have several use cases that manipulate and add to the same data at different points in the process.
Each of these use cases share many of the same models, and actions in the process but would require totally different views and structure.
I was thinking of trying out the tips in this article from 8thLight but this was written in 2007.
http://blog.8thlight.com/jim-suchy/2007/02/20/sharing-a-database-among-multiple-rails-applications.html
According to them, the trick is to
(1) make a new folder with the shared models right above the application.
applications_in_same_business_domain
|-shared_models
|-application1
|-application2
|-...
(2) require this new folder or module in your application via enviorments.rb file
(which I believe the equivalent would be config/application.rb because I don't see enviornments.rb in Rails 3.)
They say some code like this will work (in environments.rb)
$: << File.dirname(__FILE__) + '/your_lib_path'
I tried this and it isn't working (in application.rb)...
config.autoload_paths += %W(../../../mardom_shared_models)
Is this the standard way to do this?
An API sounds like another way to do this...but...I don't know anything about API's here. Self-learning 6-Month Noob here)
Helping me get the above to work if it is possible I guess would be the specific question. Can I do this?
But any comments or articles on other matter would be appreciated.
I would need to modify the Rails generators here starting from this link: http://guides.rubyonrails.org/generators.html
I would rather put all models related stuff into a gem, and install gem locally to vengor/gems directory to simplify navigating in it.