Displaying 20 results from an estimated 2000 matches similar to: "questions about cookies when bridging together two rails apps"
2010 Jan 22
11
Finding out where a variable is defined
I''m looking at code in a project. I have no clue what is being passed
into the resource parameter:
def read_authorized?(resource)
if resource.respond_to? :user_read_authorized?
resource.user_read_authorized? current_user
else
true
end
end
Is there any kind of debugging feature I can run to see what gets passed
into resource in this specific
2010 Mar 09
3
undefined method join for STRING error
Hey all,
I was converting a haml file to erb and when finished, I ran the app
and got this error message:
NoMethodError in Students#student_fail
Showing app/views/students/student_fail.erb where line #40 raised:
undefined method `join'' for #<String:0x105a5e0c8>
Extracted source (around line #40):
37:
38: <% fields << render(:partial =>
2012 Sep 08
4
dash symbol
In the example below, what is the dash doing between the class
attribute and array:
(field_helpers -
[:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each
do |selector|
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2010 Jan 30
2
undefined method 'month'
I get an undefined method month:
xml.haml:
- @results.each do |result|
%set{:month => "#{result.month}", :value => result.month}
Any suggestions?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2011 Sep 11
5
question about a where condition
Hey all,
This example of working code:
@a = @b.where(:a_group_id.ne => nil).collect { |b| b.a_group }
doesn''t make too much sense to me. For one, I am not sure what that
"ne" is doing there. Is this a postgresql thing? Second, it looks like
we are collecting active record objects where the a_group_id is null,
collecting them in an array and then invoking the a_group
2012 Jan 01
4
Chronic parsing date range in console but not in application in rails 3
Hey all,
Chronic will parse a date range in console:
Chronic.parse(1/1/2011 - 1/1/2012, :guess => false)
=> 2012-01-01 12:00:00 -0500..2012-01-01 12:00:01 -0500
However, when I use logger to check if it''s parsing in application, it
is not:
logger.info "The value of history date is #{history_date}" =>
The value of history date is 1/1/2011 - 1/1/2012
2011 Feb 10
8
rvm install 1.8.7 prompts "There has been an error while running make. Halting the installation."
I want to work with both Rails 2 and Rails 3 projects.
I have RVM installed.
When I upgraded to Rails 3, Installed RVM via terminal:
bash < <( curl http://rvm.beginrescueend.com/releases/ … ll-latest)
version=$(curl http://rvm.beginrescueend.com/releases/ … sion.txt);
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src/ && curl -O
http://rvm.beginrescueend.com/releases/ … on}.tar.gz |
2012 Feb 04
3
the ^ and % operators in context
The % is modulus (remainder) operator and ^ is bitwise. In this
context, we take a file, and go through each character and encrypt it.
But why are the ^ and % operators used here:
def encrypt(reader, writer)
key_index = 0
while not reader.eof?
clear_char = reader.getc
encrypted_char = clear_char ^ @key[key_index]
writer.putc(encrypted_char)
key_index = (key_index +
2012 Jan 22
4
undefined method `gsub!' for 2012-01-22 17:00:00 -0500..2012-01-23 00:00:00 -0500:Chronic::Span
Hey all,
I am getting this error:
NoMethodError (undefined method `gsub!'' for 2012-01-22 17:00:00
-0500..2012-01-23 00:00:00 -0500:Chronic::Span):
in this code:
date_range = Chronic.parse(the_date, :guess =>
false)
reports.sum_distance_by_date(date_range).each do |d|
u[:m] << d
end
def
2010 Apr 05
3
syntax error, unexpected '\n', expecting tASSOC
Hey all,
I get the following error. Now I know it''s related to a curly brace, but
it seems that all curly braces are properly in place. So I''m not sure
why I get this error:
SyntaxError in DashboardController#panels
rails/app/controllers/dashboard_controller.rb:170: syntax error,
unexpected ''\n'', expecting tASSOC
def panels
addDetailToContainer =
2013 May 18
3
You have already activated rake 10.0.4, but your Gemfile requires rake 10.0.3.
I''m careful to create separate gemsets for each project, so when I run
bundle install, it only installs gems for that gemset. This way gems
dont creep into the wrong projects. Now I just pulled a project from
github. I made sure I was in the correct gemset, and then I run bundle
install and it works fine. but then when I use rake to create the
database "rake db:create". I get
2012 Sep 20
2
append_features(mod)
append_features(mod)
The documentation says:
When this module is included in another, Ruby calls append_features in
this module, passing it the receiving module in mod. Ruby’s default
implementation is to add the constants, methods, and module variables
of this module to mod if this module has not already been added to mod
or one of its ancestors. See also Module#include.
What if this module is
2013 May 10
2
capistrano and scm_username and github
In the capistrano wiki, it contains this line:
set :scm_username, “foo”. If you access your source repository with a
different user name than you are logged into your local machine with,
Capistrano needs to know.
Actually the way I access my repository through my app is through ssh
keys. The only user name I have with github is the one I use to log
into github to view my repositories.
So
2013 May 07
2
Net::HTTP
I''m looking at the documentation:
http://ruby-doc.org/stdlib-2.0/libdoc/net/http/rdoc/Net/HTTP.html
And I notice two uses of Net::HTTP. Both are using GET requests. But
what''s the difference? When to use which?
Net::HTTP.start(uri.host, uri.port) do |http|
request = Net::HTTP::Get.new uri
response = http.request request # Net::HTTPResponse object
end
uri =
2011 Jun 27
2
insert value of primary key into another field before record is saved
Hey all,
I created a seed task:
def books!
books = Book.where(:type_id =>
Type.find_by_name(''Fiction'')).order(''id'')
books.each do |book|
@books = 4.times.map do |i|
subbook! "#{book.book_num}-#{i}".to_s, :book_state =>
BookState[:available].id, :book => book
end
end
puts "log it:
2013 Apr 27
3
where exactly are gems?
when you add a gem to the Gemfile and then run bundle install, where
does the command look for the gem? If you had "gem ''rails'', :git =>
''github.com/rails/rails.git", I assume it would update your
system .rvm gems directory with the latest github commits. But what is
the default repository that bundler looks for gems?
--
You received this message because
2012 Jan 21
4
why doesn't an instance of Object get Class's new instance method?
"Object is the root of Ruby''s class hierarchy. Its methods are
available to all classes unless explicitly overridden."
Wouldn''t Class class be at the root of the class hierarchy?
After all, look at this:
1.9.2p290 :006 > Object.instance_of? Class
=> true
Object is an instance of class, after all we can use one of Class''
instance methods on Object:
2012 Sep 09
2
mattr_accessor inside a class
Rails extends Ruby with mattr_accessor (Module accessor). As Ruby''s
attr_accessor generates getter/setter methods for instances,
mattr_accessor provide getter/setter methods at the module level. In
below example, you see that mattr_accessor declared in the class
context of LookupContext. It''s declared in class, not module. However,
modules are defined in LookupContext, for
2012 Sep 22
4
Class, Module, Object
>> reload!
Reloading...
=> true
>> puts Class < Module
true
=> nil
>> puts Module < Class
false
=> nil
>> puts Module < Object
true
=> nil
>> puts Object < Module
false
=> nil
>> Object.parent
=> Object
The above indicates that the Class object instance inherits from the
Module object instance and the Module object instance
2013 Apr 03
2
strange behavior with active relation any? method
In console, I run the following and any? returns true:
drivers = Driver.select("drivers.*,
drivers.id").joins([:reports, :driving_habits]).where("extract(MONTH
FROM reports.time) = ? AND extract(YEAR FROM reports.time) = ?", 3,
2013).uniq.order("drivers.id asc").page(2).per(1)
drivers.any?
=> true
This correctly evaluates to true because the relation contains one