I'm following Ryan Bates' declarative authorization railscast. I'm trying to add functionality for author of a particular article to be able to edit comments left in his article, regardless of if he is the owner or not. I tried doing it, but couldn't get it to work.
role :author do
has_permission_on :articles, :to => [:new, :creat...
An old one of my ruby on rails migrations contains both the actual migration but also an action to modify data:
class AddTypeFlagToGroup < ActiveRecord::Migration
def self.up
add_column :groups, :selection_type, :string
Group.reset_column_information
Group.transaction do
Group.all.each do |group|
group.selection...
I am using activescaffold and i want to enable search based on the created_at time of records. I have been trying out this for weeks, but havent seen any examples on the net. pls somebody help me !!
...
Does anyone know a good solution to limit the file upload size when running a Rails application with Passenger/mod_rails. The request should immediately be declined, so that the file doesn't get transferred to the server.
The solutions I've found so far all describe how to patch Mongrel to implement a limitation, but I have to use passe...
Hi all,
I have a swf file, which handels some xml data. After that process complets I am giving the data back to my rails server. My problem is, that any redirection in my rails app is handed ower to the swf file and the actual displayed page remains the same!
How can I perform a redirection in my webpage from a swf flash file.
Thanks...
Is using 50 if-else statements too resource-intensive for one action?
I'm doing something like this:
if team.players.count > 1
assign_team_type(..)
elsif team.players.count > 3
assign_team_type(..)
...
etc.
...
end
Also, is it more efficient to place the 50 if-else statements in your create action inside your controller instead...
You know how some bug trackers (and other software) allow you to add custom fields?
Typically this is done with a data structure that looks something like this:
Items
----------
ID | NAME | ITEM_TYPE_ID
FieldDefinitions
---------------------------------------
ID | ITEM_TYPE_ID | FIELD_NAME | FIELD_TYPE
FieldValues
------------...
I have been working to deploy a relatively large Rails app (Rails 2.3.5) and recently doing some load testing we discovered that the throughput for the site is way below the expected level of traffic.
We were running on a standard 32bit server, 3GB of RAM with Centos, and we were running Ruby Enterprise Edition (latest build), Passenger...
Can you have one installation of Rails and then use it for multiple apps. For example, I would like to have the following structure:
siteroot/app1 (rails)
siteroot/subsite1 (regular static html site)
siteroot/app2 (rails)
siteroot/subsite2 (regular static html site)
and so on...
What is the best practice for this?
...
I've installed paperclip to my project as plugin using
ruby script/plugin install http://github.com/thoughtbot/paperclip.git
Model:
class Company < ActiveRecord::Base
has_attached_file :logo, :styles => { :large => "300x300>", :medium => "100x100>", :thumb => "50x50>" }
validates_attachment_content_type :logo, :content_type => im...
Hi, I'm calling a rails app from another using ActiveResource. I need to supply the id of the new object to the first app (yes, controller create in this app knows how to handle receiving an id), so I do something like this:
a = ActiveResourceModel.new(:id => 1231231, :name => "test")
a.save
However, instead of doing POST to create a ...
When coding with PHP I always separate configuration values like perPage value in a separated ini file. How are you Ruby masters do this with Rails?
I would like to access config values inside my model, controller and view.
Thx!
...
#routes.rb
map.connect '/articles/new', :controller => 'articles', :action => 'new'
map.connect '/articles/:author_name', :controller => 'articles', :action => 'show'
map.connect '/articles/:author_name/edit', :controller => 'articles', :action => 'edit'
map.resources :articles, :comments
When I got to /articles/test and click delete,...
I'd like to override the typecasting that ActiveRecord is doing to my datetime fields when using a finder like .first or .all but it doesn't seem to be working the way I thought it would.. I was expecting the override to return the datetime_before_type_cast like it works when I access the field directly in the bottom example.
In my mode...
Will it finish serving all current requests before it restarts?
...
Hi,
How can I render LaTeX stuff like
\frac{1}{2}
in a Ruby on Rails application? I mean to get an image?
Thanks!
...
I want to have a "Delete"-link on a page viewing an object in my Ruby on Rails project. I am running into problems as
<%= link_to "Delete", @member, :confirm => 'Are you sure?', :method => :delete %>
loads the page it is on, when the method has run, thus trying to load a non-existent object. I would like to return to an index page, on...
ActiveRecord use to call after_save callback each time save method is called even if the model was not changed and no insert/update query spawned.
This is the default behaviour actually. And that is ok in most cases.
But some of the after_save callbacks are sensitive to the thing that if the model was actually saved or not.
Is there a...
Is it possible to specify html attributes while using the form_for helper methods?
For example:
<% form_for @user do |f| %>
<%= f.label :username%>
<%= f.text_field :username %>
<%= f.submit "Signn Up" %>
<% end %>
How would I go about specifying the class for the label? Is it possible, or do I have to resort to label()?
...
I have a users controller in my application, routed with:
map.resources :users
This has my user pages living at /users/1, and so forth.
I'd like my user pages to live at /users/blake, etc.
What's the right way to do this in rails, such that I can say link_to(@user) and the correct path is generated?
...