I'm currently working on a project in ruby, and I hit a wall on how I should proceed. In the project I'm using Dir.glob to search a directory and all of its subdirectories for certain file types and placing them into an arrays. The type of files I'm working with all have the same file name and are differentiated by their extensions. Fo...
I'm trying to put together a form_tag that edits several Shift objects. I have the form built properly, and it's passing on the correct parameters. I have verified that the parameters work with updating the objects correctly in the console. However, when I click the submit button, I get the error:
ActiveRecord::RecordNotFound in Shif...
Hi, I am using the ruby aws/s3 library to retrieve files from Amazon S3. I stream an object and write it to file as per the documentation (with debug every 100 chunks to confirm progress)
This works for small files, but randomly freezes downloading large (150MB) files on VPS Ubuntu. Fetching the same files (150MB) from my mac on a much ...
I'm looking for a way of making a method "personal" - note NOT PRIVATE to a class
here is an example - by "personal" I mean the behaviour of method "foo"
class A
def foo
"foo"
end
end
class B < A
def foo
"bar"
end
end
class C < B
end
a=A.new; b=B.new;c=C.new
I'm looking for a way of producing the following behav...
I came to ruby from PHP.
How could i do the next thing in ruby?
$className = 'ArrayObject';
$arrayObject = new $className();
Thank you for any help!
...
Can anyone recommend some RoR plugins and/or general sage that will help me with SEO?
...
I'm working with an older version of Rails and ActiveRecord that does not have the :primary_key option in has_many relationships of more recent ActiveRecord versions and unfortunately I don't get to control when we upgrade. Is there any way to hack this solution via :conditions or :finder_sql options?
...
There are only three ways to invoke install.sh
./install.sh
./install.sh --force
./install.sh -f
I can write it easily. However I am trying to make use of OptionParse. This is what I have so far.
def self.parse
option = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: ./install.sh [--force]"
opts.on...
class Person
belongs_to :team
class Status
#has last_updated property
class Team
has_many :members, :class => "Person"
Ok, so I have a Team class which has many People in it and each of those people has a status and each status has a last_updated property.
I'm currently rendering a partial with a collection similar to:
=rend...
Since it now seems to have replaced TestUnit in 1.9.1, I can't seem to find an equivalent to this. There are times when you really just want a method to run once for the suite of tests.
For now I've resorted to some lovely hackery along the lines of:
Class ParseStandardWindTest < MiniTest::Unit::TestCase
@@reader ||= PolicyDataReade...
So here is my test suite:
class ReleaseTest < ActiveSupport::TestCase
should_not_allow_values_for :title, '', 'blah', 'blah blah'
should_allow_values_for :title, 'blah - bleh', 'blah blah - bleh bleh'
def test_something
assert true
end
end
Shoulda's macros generate 5 tests, and then I have test_something below (just to se...
I'm a noob at this and can't figure out why the hyphen gets added to something like this:
<% if flash[:notice] -%>
<%= flash[:notice] %>
<% end -%>
Not even sure if my jargon in the title of this question is accurate.
...
I have a Post Class and a Comment Class. I have a post object and want to convert it to a Comment object. I went through Rails api and found becomes(klass).For now there is not association between a Post and Comment. So i tried
@post.becomes(Comment).
but becomes method could not be found for @post object. Am i missing something ?
...
Hi,
I am using facebooker in one of my applications. I want to add some application specific methods to various classes in it? e.g.
In facebooker/lib/facebooker/models/user.rb
module Facebooker
class User
# I want to add my methods here. for e.g my_method
end
end
I can not directly put my_method in the plugin itself since I ...
Based on their design philosophy, it sounds like they want gem users to hand code ruby proxy classes. I still feel that they could have provided generators.
Any suggestions on how to generate maintainable ruby proxy classes for savon or handsoap?
...
How do you disable code completion in NetBeans on Ruby?
...
My model class is:
class Category < ActiveRecord::Base
acts_as_nested_set
has_many :children, :foreign_key => "parent_id", :class_name => 'Category'
belongs_to :parent, :foreign_key => "parent_id", :class_name => 'Category'
def to_param
slug
end
end
Is it possible to have such recursive route like this:
/root_category...
Hey,
Im sure I am missing something here but none the less.
foo['bar'] = nil
if(foo['bar'] == nil)
puts "foo bar is nil :("
However, nothing happens? Any thoughts?
...
I have this in my user.rb:
attr_accessor :old_password
def validate
unless password.nil?
errors.add_to_base("Old password entered incorrect") unless self.valid_password? old_password
end
end
I have old_password as a a virtual attribute that has to be validated as matching with the current before updating to a ne...
I've scaffolded Things element:
script/generate scaffold wip/thing name:string
and got some invalid function call in views, like:
<td><%= link_to 'Edit', edit_thing_path(thing) %></td>
Which raise this error:
ActionView::TemplateError (undefined method `edit_thing_path' for #<ActionView::Base:0xb5c00944>) on line #11 of app/views/...