I have an Organization that has_many Affiliations And a mission that has_one Organization
So i can do this:
m = Mission.first
m.organization.affiliations
A user also has_many affiliations so I can do:
u = User.first
u.affiliations
In declarative_authorization I want a user to be able to manage a mission if he is affiliated to the ...
I know, if i will write "redirect_to" instead of "render :action", i'll lose my @object's errors.
My code:
def play
@room = params[:id][0,1]
@current_players = CurrentPlayer.all(:conditions => {:room => @room})
end
def join
@new_player = CurrentPlayer.new(:user_id => current_user.id, :team_id => nil, :room => params...
I'm making a Rails application.
In the one action I need to spawn a long running process.
This is not a problem. I can fork new process using spawn gem or some other.
But some time after process has been spawned,
user must be able to pass additional data to that process.
Sure, I can fork process which will listen a UNIX socket,
store so...
I am extending the shopping cart model (from Agile Web Development with Rails) that lets a user 'add to cart' a product_id through the session. The id is only stored in the database (as a line_item) after a user clicks 'checkout'.
Id like to attach other unique data related to that line_item, like color and special_instructions, through...
Attempting to pull my database from Heroku gives an error partway through the process (below).
Using: Snow Leopard; heroku-1.8.2; taps-0.2.26; rails-2.3.5; mysql-5.1.42. Database is smallish, as you can see from the error message.
Heroku tech support says it's a problem on my system, but offers nothing in the way of how to solve it.
I...
Since Rails is fully compliant with Rack I was wandering how I would set up a rackup file so that a Rails application is just a piece of middleware and then a request could hit another app further down the middleware stack.
What I really want is to use a Rails app to handle authentication and authorization for smaller rack-apps later on...
I am trying to create a tabbed interface using the prototype helper method "replace_html." I have three different partials I am working with. The first one is the 'main tab' and it is loaded automatically like so:
<div id = "grid">
<% things_today = things.find_things_today %>
<%= render :partial => "/todaything", :collection ...
I have a Reports controller and various reports:
http://localhost/reports/main/this_month
http://localhost/reports/main/last_month
http://localhost/reports/main/this_year
I wanted http://localhost to default to http://localhost/reports/main/this_month. That is easy enough using map.root in my routes.rb.
However when I do this any lin...
Rails: I need to set a condition in a has_many that needs the self.id variable
I need something like this:
has_many :posts, :conditions => "posts.hello_id = #{self.id}"
but self.id there it just doesnt work :s
...
belongs_to :removed_friend,
:class_name => 'Profile',
:foreign_key => "(CASE WHEN friendships.profile_id = #{self.id} THEN friendships.friend_id ELSE friendships.profile_id END)"
The self.id its not working too :s it should be the id of the profile that is triggered the action.
Anyway the main problem is that this fore...
My Rails application crashes intermittently with the following message:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/multibyte/utils.rb:52: [BUG] gc_sweep(): unknown data type 0x0(0xbdc2ca0)
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.01
I am running the a...
hi,
Am new to ruby.
Can any one tell me how to find inverse of a number in ruby.Is there any function for it?
or just 1/number ?
Thanks in advance.
...
I have a string of words; let's call them bad:
bad = "foo bar baz"
I can keep this string as a whitespace separated string, or as a list:
bad = bad.split(" ");
If I have another string, like so:
str = "This is my first foo string"
What's the fasted way to check if any word from the bad string is within my comparison string, and ...
Can anyone point me to a plugin/directions for enabling emails through a smtp server requiring encryption? I've done some searching and found http://agilewebdevelopment.com/plugins/actionmailer_tls , but the download is down, a pattern repeated with several other plugins also.
...
I'm looking for plugins that will allow my codebase to interact with, browse, and poll an SVN server for information about a repository.
Trac can do this, but I was hoping there was an easy-to-use library available to accomplish the task, rather than trolling through the Trac codebase. Googling for this returns mostly vague results abo...
I know similar questions have been answered before - such as: Where should logic go, where to do certain tasks, etc. But I have a more specific question - How far should I take this axiom: "keep your controller skinny, make your model fat!"
Here is an example:
For instance let's say I have multiple source of verification data. A good e...
Guys,
Long time Java developer here, but I've spent more time working with Ruby over the past 3 years or so as far as web applications go. I really have enjoyed it, but there are concerns I've uncovered that I won't cover here.
Now that I've found the Play! framework, I'm thrilled about the prospect of having a Rails-like experience wi...
Where do most Rails apps usually keep their non-active-record classes?
In app/models?
In lib/some_file.rb?
Someplace else?
...
Hi, everybody!
I'm new on both this site and ruby on rails!
I have a common installation of authlogic and want password to be generated automaticly for user registration if user did not set the password. What is the best way to do it?
...
Hi everybody,
I have a web application which has some multimedia files stored in a user protected area. To make these files available to logged in customers, I consider using the x-sendfile plugin.
x_send_file(path, :type => 'application/pdf')
It is just strange that every time I run this function an empty file gets sent to the brows...