Linked Questions

62 votes
2 answers
50k views

helper.method_name worked in some version of Rails... are there ways that work in both Rails 2.2.2, 2.3.5, and 3.0.1? (to use all view and helper methods)
nonopolarity's user avatar
31 votes
2 answers
11k views

I have a datetime attribute on a record: 1.9.3p194 :024> f.last_contact => Thu, 11 Aug 2011 00:00:00 UTC +00:00 But when I try time_ago_in_words at the console, it doesn't work: > ...
marcamillion's user avatar
  • 33.9k
22 votes
3 answers
20k views

I'm using Rails 4.0.3. How do I render a partial from the Rails console?
Chloe's user avatar
  • 26.5k
15 votes
3 answers
26k views

In Rails, supposing that the file is already loaded, how it is possible to call my_method from this example from console? # some_file.rb class MyClass < ApplicationController::Base def ...
Martin's user avatar
  • 11.3k
15 votes
4 answers
10k views

Probably doing something stupid here, but here's my basic cookie cutter class: class League < ActiveRecord::Base private def league_params params.require(:full_name).permit! ...
randombits's user avatar
  • 48.7k
6 votes
1 answer
12k views

I have a controller sessions that can create session. I'd like to call it from the console, like controller.create. Here is the action: def create #raise request.env["omniauth.auth"].to_yaml ...
daniel's user avatar
  • 9,845
5 votes
3 answers
5k views

I'm trying to make an authenticated post request, and I need the CSRF. When I log in, it isn't generating the _csrf_token for some reason: 2.0.0p247 :126 > app.post '/community_members/login', {"...
Chloe's user avatar
  • 26.5k
3 votes
3 answers
4k views

I'm trying to test out some helpers in the rails console. I read another answer that describes some techniques. In my first attempt I start calling my helpers on the helpers object: [10] pry(main)&...
mbigras's user avatar
  • 8,105
6 votes
2 answers
4k views

If I have a controller concern, for example: module MyConcern def concern_method param puts param.inspect end end How can I test the method concern_method from the console? Using methods ...
koosa's user avatar
  • 3,040
2 votes
2 answers
12k views

I'm trying to create a cron job using the whenever gem to send birthday reminders to users and i want this cron to run everyday. I have the whenever gem working, but my cron job keeps erroring out. I'...
Catfish's user avatar
  • 19.4k
5 votes
3 answers
2k views

Let's say I have a Product model and ProductsController. Controller has all the standard CRUD method and Product does all kinds of validations etc. Here is an issue. I have several custom very ...
konung's user avatar
  • 7,056
4 votes
1 answer
2k views

I want to dispatch (route and render) from a model. (I only care about GET requests and I ignore Accept: headers, so I only look at PATH_INFO.) # app/models/response.rb class Response < ...
Seamus Abshere's user avatar
3 votes
1 answer
2k views

I thought Ruby on Rails "script/console" can let me do "render :text => 'hello' " but it says render is not defined?
nonopolarity's user avatar
4 votes
2 answers
1k views

I'm trying to do a little testing of the number_to_currency method, but no matter how I try and call it in the console I'm out of luck it seems. ActionView::Helpers::NumberHelper::number_to_currency ...
Jeremy's user avatar
  • 685
7 votes
1 answer
2k views

Is it possible to render a partial from inside a ruby script or from the the rails console? How would one go about doing this?
recursive_acronym's user avatar

15 30 50 per page