G'day guys, I'm currently using fastercsv to construct ActiveRecord elements and I can't for the life of me see this bug (tired), but for some reason when it creates, if in the rake file i output the column I want to save as the element value, it puts out correctly, as either a Trade or a Quote
but when I try to save it into the activer...
My situation is like this.
Company has many users and users may belongs to many companies.
And current implementation is something like below.
class Company
has_many :employments
has_many :users, :through => :employments
end
class Employment
belongs_to :company
belongs_to :user
end
class User
has_m...
G'day guys, I have a current set of data, and I generate multiple analyses of this data (each analysis into its own active record item called a pricing_interval) using a helper function at the moment.
Currently to analyse the set of data, you need a start time(using datetime_select) an integer (using text_field) and a name (using text_f...
Here's what I've tried:
1. gem install awesome_print
2. echo "require 'ap'" >> ~/.irbrc
3. chmod u+x ~/.irbrc
4. script/console
5. ap { :test => 'value' }
Result:
NameError: undefined local variable or method `ap' for #
...
When I render XML with an :include clause for a polymorphic association I have, it doesn't work. I end up with the XML returning the object pointers instead of the actual objects, like:
<posts>
#<Comment:0x102ed1540>#<Comment:0x102ecaa38>#<Comment:0x102ec7fe0>#<Comment:0x102ec3cd8>
</posts>
Yet as_json works! When I render JSON wit...
I'm creating a simple paste-bin in Ruby on Rails, which will have an expire-feature. With this, people can select a date when the paste will be deleted automatically. How can I implement this? I was thinking of a cronjob, but maybe there is a more platform-independent way, by defining this in the model itself. Can anyone help me? Thanks....
I have two roles in devise. The first is the admin and the second the normal user-role.
Now I´d like to give these two groups in some cases same rights with before filters.
How does this work?
I have:
before_filter :authenticate_user!, :only => [:new, :create]
before_filter :authenticate_admin!, :only => [:new, :create, :edit, :update...
I'm using dragonfly gem to manage images and attachments in my rails app and I need to store images in a specific directory structure based on my
user model.
let' say I have user model which has a name and each user has many
albums, which have a name also, then I want the images to be stored
in "#{RAILS_ROOT}/public/system/#{user.name}/...
When I write
module ApplicationHelper
def flash_helper
flash.each do |key, msg|
content_tag :div, msg, :class => key
## "<div class=\"key\">" + msg + "</div>"
end
end
end
I do not get anything unless I return the statement. The HTML is escaped in my view when I call <%= flash_helper %>. What gives? How can ...
My error messages in Rails look like the following:
"Email Your email is invalid."
Why is the name of the field prefixed within the string itself? It makes the error messages look awfully odd.
Is there anyway to circumvent this behavior so that I can just see "Your email is invalid."
...
Hello, I am using the
http://github.com/collectiveidea/awesome_nested_set
awesome nested set plugin and currently, if I choose a sub category as my category_id for an item, I can not search by its parent.
Category.parent
Category.Child
I choose Category.child as the category that my item is in. So now my item has category_id ...
I'm creating a Rails application which uses MySQL. I have a table in my DB like this:
create_table "pastes", :force => true do |t|
t.string "title"
t.text "body"
t.string "syntax"
t.boolean "private"
t.datetime "expire"
t.string "password"
t.datetime "created_at"
t.datetime "updated_at"
end...
I am having some serious problems, however this seems to be a common thing. I have Snow Leopard 10.6.3 and here are my other version info:
MySQL
mysql Ver 14.14 Distrib 5.1.46, for apple-darwin10.2.0 (i386) using readline 5.1
gem 1.3.6
ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
My problem is that no...
Can I assert rails/sinatra apps are initialized only once and all requests share the same app
instance? or do new requests spawn new app instances?
Is it possible to instance custom classes and persist them during app lifetime without using sessions, database storages or third party services? If so, what are the implications from a thr...
I'm trying to calculate the data needed to generate a box plot which means I need to figure out the 1st and 3rd Quartiles along with the median. I have found some solutions for doing it in Postgresql however they seem to depend on either PL/Python or PL/R which it seems like Heroku does not have either enabled for their postgresql datab...
i am interested in creating a rails app with a mysql database. i am new to rails and am just trying to start creating something simple:
rails -d mysql MyMoviesSQL
cd MyMoviesSQL
script/generate scaffold Movies title:string rating:integer
rake db:migrate
i am seeing the following error:
rake aborted!
NoMethodError: undefined method `o...
I have two models:
class Employee < ActiveRecord::Base
has_many :projects
end
class Project < ActiveRecord::Base
acts_as_taggable_on :skills, :roles
end
I would like to find Employees using the tags associated with their projects. The geokit-rails plugin supports a similar concept, using its ':through' relationship.
Ideally, I ...
I can't figure out what I'm doing wrong here.
I can’t seem to get the #{@user.name} to work in my flash[:notice]
Everything else works just fine I can add new users, but when I add a new user instead of saying “User John Doe was successfully created”, it says “User #{@user.name} was successfully created.”
I'm at this point in the dep...
I'm trying to use mikel gem mail on my 2.3.5 Rails App
http://github.com/mikel/mail
I have it working like this.
I've made a MailComHelper, made a method like this :
def self.welcome(user,password)
@user = user
m = Mail.new
m.from = '[email protected]'
m.to = @user.email
m.subject = 'welcome'
m.body = 'The body'
m...
I have an Adult model with a name attribute.
If the user is logged in, I want the Adult.name to only return the first name.
Is there a way to have helpers tied to a model where you could specify Adult.helper.name?
Or a least have helpers namespaced to a model?
...