I am developing a (currently) Rails 2.3.x application with a PostgreSQL 8.4 database backend. In my Rails application, I have a model corresponding to a database table that has two columns of datatype SERIAL and set as NOT NULL. I have one of these columns set as the primary key in both Rails and as a PostgreSQL constraint.
Table defin...
I'm building a form to allow a user to CRUD a project permission.
....
<% roles = Role.all %>
<%= f.collection_select :role_id, roles, :id, :name, :prompt => true %>
Problems with the above, while it renders:
If a value matches, it shows that in the dropdown as selected, which is good. Problem, is if a user is set as ADMIN. It's ea...
Hello,
I'm using paperclip, and have several styles:
:styles => {:large => "300x300>", :medium => "150x150>", :small => "50x50>", :thumb => "30x30>" }
The issue is default_stype, only applies to one of the sizes...
:default_style => :thumb,
:default_url => url here....
How can I set default_stypes for each style type? so if I call:...
I'm very new to Rails. Basically, I have a Sound model that uploads an audio file(wav) and store it somewhere on the local machine (for testing). How to set it up using Paperclip? I googled but unfortunately most of the tutorials are about image uploading:-(
Any inputs are greatly appreciated.
...
How add hash parameter to url using redirect_to?
For example:
http://localhost/products/#{page:2}
...
Here is my Gemfile
gem 'rails', '3.0.0'
...
gem 'haml-rails'
gem 'jquery-rails'
group :test do
gem 'shoulda'
gem 'rspec'
gem 'rspec-rails'
gem 'factory_girl'
end
gem 'rails3-generators', :group => :development
...
I run bundle install/update. And then not all new generators (from rails3-generators) are added. haml generators...
I have a form which i'd like to simplify. I'm recording a startdate and an enddate, but would like to show the user only a startdate and then a drop down with number of days.
But I'm having problems with my model and storing it correctly.
The first part works.
def date=(thedate)
#puts the startdate in the correct format...
...
I need an easy way to grab layouts that are found in /app/views/layouts. I technically can go in there from Rails.root and grab all files I can, but I'm sure there's a better way.
Rails knows where to look for layouts and what extensions are ok. I tried to dig through actionpack but nothing popped out at me.
Thanks
...
I have trouble with using Arel to aggregate 2 columns in the same query. When I run this, the whole server freezes for a minute, before the rails dev-server crashes. I suspect an infinite loop :).
Maybe I have misunderstood the whole concept of Arel, and I would be grateful if anybody could have a look at it.
The expected result of th...
Hello,
I'd like to retrieve the value of 'q' in this URL:
http://www.google.com/url?sa=X&q=http://nashville.broadwayworld.com/article/Just_in_time_for_Halloween_Circle_Players_does_JEKYLL_HYDE_20101013&ct=ga&cad=:s7:f1:v1:d2:i0:lt:e0:p0:t1286988171:&cd=yQoOdKUFTLo&usg=AFQjCNEg2inHF8hXGEvG-TxMQyMx7YGHkA
if I use thi...
Dear all,
I'm working on a rails3 app and I'm a little bit confused with Active Model.
Here is my model :
class MyClass
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :foo, :foo1, foo2
def initialize(attributes = {})
attributes.each { |key, value| send "#{key}=", va...
I'm trying to set up a rather complex form using form_for. This form needs to be in multiple views, where some fields would be available across all actions and other fields are specific to each individual actions.
I thought that in order to save myself code duplication, I would use a layout to render the general part, like this:
# layo...
I am new to cucumber.
And for most of the site's functionality, you have to be logged in.
So when writing cucumber, do you write, given that I am logged in for every step definition?
...
For example I have a comments models, and I have a post model, but comments can comment on other comments.
So it seems I need a join table I'll call commentables. To create this, do I really need to create a commentable table with a post_id and a comment_id ?
Or can I do something like this without one :
has_many :comments...
I'm not exactly sure what my problem is, so this question may require some more clarification, but here's what seems to be most relevant:
I have a has_many :through and the join model has some fields that aren't foreign keys. When I build the models up and try to save I get a validation error on the non-foreign key fields from the join...
I have one bit of javascript that fires off an ajax request, the result of which gets loaded into a popup dialog.
This is the same javascript in all cases, but in one case, the route fails.
From the new_army_list page:
Started POST "/army_lists/preview" for 127.0.0.1 at 2010-10-13 21:42:15 -0400
Processing by ArmyListsController#previ...
I am writing an application that contains a database with several tables and joining tables and so forth... the two I am working with currently (and am stumped on) are my pages table and my templates table.
Now a page can contain only one template, but a template can have many pages.
Model for Page:
class Page < ActiveRecord::Base
h...
I'm fairly new to rails, working on a Rails 3 app with a Profile model for users.
In the profile Model I'd like to have a "name" entry, and I'd like to be able to access logical variations of it using simple syntax like:
user.profile.name = "John Doe"
user.profile.name.first = "John"
user.profile.name.last = "Doe"
Is this possible, o...
Hello, rails 3 seems to escape everything, including html. I have tried using raw() but it still escapes html. Is there a workaround? This is my helper that I am using (/helpers/application_helper.rb):
module ApplicationHelper
def good_time(status = true)
res = ""
if status == true
res << "Status is true, with a long ...
I know that "helpers" are usually for views/templates. But say I have a helper method that I want to call from different controllers. Where should this file go?
I was thinking of creating a helper module in the "models" folder but I'd like to know if there's a "correct" way to do this.
...