I'm new to Rails. I'm building an app that has a user model and a profile model.
I want to associate these models such that:
- After the user creates an account, he is automatically sent to the "create profile" page, and the profile he creates is connected to only that particular user.
- Only the user who owns the profile can edit ...
I'm using active_delegate for multiple connection in Rails. Here I'm using mysql as master_database for some models,and postgresql for some other models.
Problem is that when I try to access the mysql models, I'm getting the error below! Stack trace shows that, it is still using the postgresql adapter to access my mysql models!
Runtime...
Its maybe not the best solution in most cases, but i want a table with data form 3 tables.
class Media < ActiveRecord::Base
belongs_to :user
belongs_to :type
has_many :ratings
end
class User < ActiveRecord::Base
has_many :medias
has_many :ratings
end
class Rating < ActiveRecord::Bas...
When using the new accepts_nested_attributes_for in ActiveRecord, it's possible to use the option :allow_destroy => true. When this option is set, any hash containing nested attributes like {"_delete"=>"1", "id"=>"..."} passed to update_attributes will delete the nested object.
Simple setup:
class Forum < ActiveRecord::Base
has_many ...
I have a namespace with different tasks:
namespace :mytest do
task :setup do; ... end;
task :task1 do; ... end;
task :task2 do; ... end;
end
When I run cap mytest I get the task `backup' does not exist.
How do I create a command which calls all tasks?
...
I'm running into a CookieOverflow error, so I want to switch to database sessions.
In config/environment.rb:
Uncommented: config.action_controller.session_store = :active_record_store
Changed: :secret for config.action_controller.session
In application.rb:
Uncommented: protect_from_forgery :secret => 'ac44a970c0047c1b049c1967986af6...
Hey Guys,
I'm creating my first rails app, and using the standard prototype library for some effects. I recently brought in Thickbox which is breaking all of the previous effects.
I know there is a no conflict method for jQuery but I'm not exactly sure how to implement it?
Should I just do a find/replace for $ in the jquery and thickb...
Is it possible to map a subdomain to a resource? I have a company model. Currently, using subdomain_fu, my routing file contains:
map.company_root '', :controller => 'companies', :action => 'show',
:conditions => { :subdomain => /.+/ }
My Company model contains a "subdomain" column.
Whilst this works as inten...
Hello,
Hoping some learned Rails developers here can recommend an existing Ruby on Rails plugin or gem that allows you to continue using the Simple I18n backend whilst allowing you to optionally specify translations in the database.
Here's why:
I have one Rails app used for many websites. For the example I'll just use 2 websites:
We...
Is there an easy way to have a rails action load up an external file of commands and then execute them?
For example, I'm trying to write a bunch of rails create methods to pre-populate a bunch of tables in a database.
Ideally, I'd like the action to check for the existence of the file, if it exists, run all of the commands, and then de...
WARNING: Complete newbie to RoR and Ruby alert! *
I have a login method that looks like this:
@user = Person.find(:first, :conditions => ["email=?", params[:email]])
if @user and @user.password==params[:user_password]
session[:user] = @user
else
flash[:warn] = 'Invalid password!'
However, the user record can get very large, ...
We are trying to use google analytics and hubspot on our site but they bith seem to delay the execution of the scripts on our site.
We are using jQuery and the "ready" function to delay our scripts until the page is ready.
Are there any ways we can delay the analytics scripts and have our scripts execute first?
Thanks.
...
I am getting the average of all of the calls that belong to a user. A user can have many phones. So I search all the phones that belong to that user and average that phones calls and add it to an array. Now I need to average all of the calls together. This is what comes back:
[{["2009-08-14", #<BigDecimal:87e1488,'0.81E2',4(8)>]=>nil,
[...
What is the difference between Marshalling and ActiveRecord Serialization?
Is there any particular occasion when it is preferable to use one over the other to save an object to the database?
...
Coming from a long history of C-style syntax and now trying to learn Ruby (on Rails), I've been having my share of issues with its idioms and such, but today I hit one I didn't expect to have a problem with and I can't see whatever it is that must be right in front of my face.
I have a Binary class that includes a private method to deri...
I'm planning an XMPP bot system in which a bot is "attached" to a Rails app in background to receive commands and so on. Is is appropriate to use the same account for all apps (40+) and just changed the resource part, like this:
account@host/bot1
account@host/bot2
account@host/bot2
or use totally different JIDs, like:
account1@host
...
I'm looking for a more simple text editor than TinyMCE for use with Rails, I find MCE editor, bloated, cumbersome, and problematic with many things.
...
I am working on rails with rspec, rspec-rails, cucumber and webrat.
I am trying to learn BDD and testing in general.
I have a cucumber scenario like this:
Scenario: Questions List
Given quiz titled "Pearl Jam" has questions named "Corduroy, Dissident"
When I go to the experiment page for quiz titled "Pearl Jam"
Then I shou...
You know, like myblog.com/posts/donald-e-knuth.
Should I do this with the built in parameterize method?
What about a plugin? I could imagine a plugin being nice for handling duplicate slugs, etc. Here are some popular Github plugins -- does anyone have any experience with them?
http://github.com/rsl/stringex/tree/master
http://github...
So I have some data loading in migrations, for instance a default user is created when the users table is made, and certain user Roles are created (like foo_admin) are created when the foos table is made.
The problem is cucumber doesn't like this, since it does a schema load.
Can I either make cucumber just run the migrations instead, ...