I'm working on a new project and for some reason decided to create two separate user models/controllers/sessions using authologic.
The users have completely different roles on the site but the models are basically the same. The only difference is the views.
I'm now wondering if I should have just created one model and added a "role" f...
I want to use the methods I defined in app/helpers/annotations_helper.rb in my ReportMailer views (app/views/report_mailer/usage_report.text.html.erb). How do I do this?
Based on this guide it seems like the add_template_helper(helper_module) method might do what I want, but I can't figure out how to use it.
(BTW, is there a reason you...
I'm trying to figure out how to have a two level user relationship.
Photographers have clients. Clients have one photographer. Both are Users.
I've got a User model that looks like this:
class User < ActiveRecord::Base
#authlogic
has_many :client_associations,
:foreign_key => 'client_id',
:class_name => 'Association',...
I have two attributes, 'a_value' and 'b_id'. (Not their real names.) 'a_value' is stored on the file system, using some information from model 'B', referenced by 'b_id'.
So, my params object looks like:
params[:foo] = {"a_value"=>"nifty value","b_id"=>"38"}
for example.
Now, in foo_controller.rb:
foo = Foo.new(params[:foo])
But t...
Hello there,
I was wondering why when you create restful routes in rails with map.resources it generates actions for new, create, edit, update?
Is there anything wrong in declaring just one action for create and update
and do something like this?
def create
unless post?
@user = User.new
else
redirect_to :action => 'index' ...
I'm aware that I can check an ActiveRecord through the rails console but it shows the entire output in one line. This can be an issue to look up a specific attribute if the table has many columns.
>> Story
=> Story(id: integer, name: string, link: string, created_at: datetime, updated_at: datetime)
I like how the attributes are disp...
In ruby on rails how do I find the top 3 records of my table called notices ordered by a particular field, in my case I want to order by the position field which is an integer.
so my notices table looks like this
any help would be greatly appreciated, thanks
...
I have an ActiveRecord model with a field called name (in the database) and a method called collation_name (not in the database) that returns a reduced version of the name. The model class resembles this:
class Foo < ActiveRecord::Base
# ... other stuff ...
def collation_name
words = name.downcase.split
if words[0] == 'the...
I'm working my way through Agile Web Development with Rails and am running into this problem on a shared system (Dreamhost).
[******]$ ruby script/generate controller Say
Rails requires RubyGems >= 1.3.2 (you have 1.3.1). Please `gem update --system` and try again.
[******]$ gem update --system
Updating RubyGems
Updating rubygems-updat...
I would like to analyse data in my database to find out how many times certain words appear.
Ideally I would like a list of the top 20 words used in a particular column.
What would be the easiest way of going about this.
...
Hi I am a complete newbie getting my feet with Rails, Please can someone help me in understanding the flow of the code
How CreditCardCallbacks, def before_validation(model) is invoked when we are not calling it directly.
class CreditCardCallbacks
# Normalize the credit card number
def before_validation(model)
model.cc_number.gsub!(/[-\...
I've been working a lot with Ruby on Rails in the past several months, and am loving it. Recently however, I've come into some work that requires PHP, and would like to retain a lot of the nice baked in features that Rails provides, such as:
Restful Routes
Easy Model Validation
Good Application Layout
Helpers and Observers
Are there...
Please let us know if we can integrate a "Moneybooker"' payment gateway with the Rails application.
We are trying for it and succeeded to some extent, however during integration we need to specify the url, where the user would be directed after successful transaction and it does happen. But once we get the success message, we get a mail...
Hello,
I have a Ruby on Rails application that will be a CMS in way which means it's mostly DB intensive. I expect it to have decent amount of traffic so before designing I'm choosing what servers to use. Most important for me is performance.
I heard good things about Nginx and many developers in the Rails community recommends it my on...
Hi,
I'm running Rails 2.3.3 application which is deployed with passenger/mod_rails with ruby-enterprise-1.8.6-20090610 and apache httpd.
The problem is that whenever I deploy our application, hundreds of httpd processes start dying. I'm getting this error:
[notice] child pid NNNNN exit signal Segmentation fault(11)
After a short p...
My Rails app uses the TMail plugin, but it requires a modification to Attachment.rb.
The modification is recognized and loaded by Rails on my development machine, but in the production environment on my hosting provider (Rails Playground), the system version of TMail is loaded and not our custom version.
Online document about the best ...
i am creating a simple shopping cart in rails, when I add the product to cart i get this error :
You have a nil object when you didn't expect it!
the add to cart method is :
def add_to_cart
begin
product = Product.find(params[:id])
rescue ActiveRecord::RecordNotFound
logger.error("Attemp to access invalid produc...
Hi I am a newbie, please forgive me if I am asking silly question. After I created
the controller, views and Model using scafolding for article
I see same code in both new and edit views.
<% form_for(@article) do |f| %>
<%= f.error_messages %>
..................
<p>
<%= f.submit "Updaggggte" %>
</p>
<% end %>
when I ch...
Hello,
I'm building Rails application and I want to have user registration/login functionality. I also need to have other fields in the User's model such address(street, city, country), facebook info, twitter info, last login time...etc
From a design perspective, is it better to have the User model very light-weight and have just usern...
Say I have Project, that is in many-to-many association with Tag. I'm using *has_many through* so I have separate join model.
How do I create validation, that checks uniqueness of join model? Now I have only
has_many :tags, :through => :taggings, :uniq => true
But that doesn't validate on save.
...