I'm aware of how include? works, however not really clear using it with multidimensional array, or a hash (is this possible with a hash?)
For example, given I have a hash that looks like:
@user.badges => [{:id => 1, :name => 'blahh', :description => 'blah blah blah'}, {:id => 2, :name => 'blahh', :description => 'blah blah blah'}]
Can...
I have recently implemented something in a rails application that allows me to read appointments of the Outlook calendar. This works sufficiently well. But when I tried to use it in production mode by starting it through mongrel_service, the whole thing stopped working and gave me the following error message:
failed to create WIN32OLE o...
Hi, little help needed
got 2 models:
class User < ActiveRecord::Base
has_many :posts
end
and
class Post < ActiveRecord::Base
belongs_to :user
end
the Posts table has a column: u_hash. This is supposed to be a randomly generated identifying hash (for public viewing). What is the best way to generate this hash and how can I add ...
I installed redmine on the apache and used mod_ruby first, which was incredible slow... now i switched to phusion passenger but the response time is still really slow ( talking about 5-6 seconds here, even using a wget to localhost from the server itself.. )
i just removed the "old" mods from the apache dir, but it's still slow... anywa...
Sometimes it's more convenient to print in <%%>. How to do it in Rails?
...
Hi,
I upload images to my App using Ajax and an Iframe. In Development everything works like a charm. But in production Nginx suddenly raises a 404 error. When I look into the log, the request never hits the Rails app. So I guess it has something to do with my Nginx configuration (maybe gzip compression).
The failing requests is send t...
I have model represent association rule (Body => Head)
def Item
has_many :heads
has_many :bodies
...
end
def Rule
has_many :heads
has_many :bodies
...
end
def Body
belongs_to :item
belongs_to :rule
...
end
def Head
belongs_to :item
belongs_to :rule
...
end
I want to find rule that have body's item matched items specified and want t...
I was wondering if the strategy I'm using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate.
For tagging I just tag a commit of the master trunk.
If it happens I have to hotfix the tag, I'm checking out the tag (e.g. 1.0), fix the issue, commit it and re-tag it (e.g. 1.0.1).
Now,...
Lately I have been trying out Rails, and I came to love the respond_to.
Is it possible to do something like this in PHP?, responding to different types of requests. So it is easy to implement an alternate way even if javascript is disabled.
...
I've installed super_exception_notifier by running:
sudo gem install super_exception_notifier
and then I've tried enabling it in my project (which already has mailing working, since it sends emails for other purposes) like this. On environment.rb I added
# Notification configuration
require 'exception_notifier'
ExceptionNotifier.conf...
I am using Composite Primary Keys plugin and everything is working fine except timestamps. When i insert new row to table that has composite primary key , created_at and updated_at columns became NULL. What can be the problem ? Any help is appreciated.
...
I'm on Snow Leopard and installed ruby, rubygems and rails the hivelogic way. When I change to my new jekyll project (~/Documents/blog/jekyll), and run
[jekyll]$jekyll --server-bash
I get:
[jekyll]$jekyll --server-bash: /usr/bin/jekyll: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such fil...
I have a bit of code that basically displays the last x (variable, but let's say x is 20 here) updates made in a given table. In one of the unit tests for it, I have this snippet:
EditedItem.push_to_queue(hiddennow)
#create some new entries and save them
20.times{ EditedItem.push_to_queue(random_item) }
Queue.get_entries.each{|entry| a...
In a Rails application, if I group several stylesheets into one using caching, will the resulting file be automatically refreshed when one of the stylesheets is updated ?
stylesheet_link_tag "style1.css", "style2.css", :cache => "mystyles"
And, if not, how can I expire the resulting file ?
...
Hi, i have looked through the list of related questions however my problem does not seem to be listed and hence here it is:
Basically I'm trying to use Geokit within the Ruby on Rails environment, im not sure if i installed it properly, I have included it within the environment.rb (and done rake db:install) and i'm now trying to do the ...
Oddly enough, most of this works as it has been written, however I'm not sure how I can evaluate if the current_user has a badge, (all the relationships are proper, I am only having trouble with my methods in my class (which should partially be moved into a lib or something), regardless, the issue is specifically 1) checking if the curre...
Once again, I have my form_for for my Order model, which has_many :services, :through => :requests. Here's the layout of how I have my relationships mapped:
__________ _________
| Customer | | Utility |
---------- ---------
|| ^ ...
Is there any way I can use the :limit and :order options in the find method. I'm trying to sort activities by descending order, such that the newest activities are shown. However, when I try to use the (:all, :limit => 5, :order=> 'Date desc) I get an error. I need to limit to only 5 records, and when I disregard the order option, it wo...
I have a AudioFile that has_many photos. A photo has an attribute "primary" (0 or 1 in db) What is an idiomatic ruby way of doing something like this: I want to have a method on the AudioFile which returns the id of the primary photo, i.e the photo that has primary attribute set to true.
...
There are 2 methods I want to call after every state transition. Right now I'm doing:
aasm_event :nominate_for_publishing, :before => [:set_state_last_updated_by, :set_state_updated_at] do
transitions :to => :under_review, :from => [:work_in_progress]
end
aasm_event :publish, :before => [:set_state_last_updated_by, :set_state...