Hi,
I have a has and belongs to many relation between User and Article
models, and I would like to link them even if an article if not hosted
on the same database then a user.
For example, If an article exists at foo.com/articles/3 and a
user exists at bar.com/users/1, If would like to be able to do
from foo.com web interface or bar.co...
I want a flash message that looks something like:
"That confirmation link is invalid or expired. Click here to have a new one generated."
Where "click here" is of course a link to another action in the app where a new confirmation link can be generated. Two drawbacks: One, since link_to isn't defined in the controller where the flash m...
I'm trying to install Rails 3 on a brand new MacBook Pro running OS X 10.6.3, Ruby 1.8.7, and Rails 2.3.5 and I'm wondering if I've hosed myself. So far, I've run these commands:
$ gem update --system
$ gem install arel tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install rail...
I have a query used for statistical purposes. It breaks down the number of users that have logged-in a given number of times. User has_many installations and installation has a login_count.
select total_login as 'logins', count(*) as `users`
from (select u.user_id, sum(login_count) as total_login
from user u
...
Hi,
Some methods have been deprecated with Rails3.
It is the case in particular with the following call !
Error.find(:all, :select => 'DISTINCT type')
Is anybody have an idea, how to convert this call to an ActiveRecord3 valid statement ?
I found nothing on the web ...
Thanks
...
Hey i got an White Macbook and, has to go in 10 hours to a conference. And I'm having a lot of problems.
First, I wanted to have Rails 3, so I used MacPorts to install Ruby 1.8.7. It worked well ;)
So now I was thinking I should install Rails 3.. but no, no!.. it says..
$ sudo gem install rails --pre
ERROR: Error installing...
I have 2 RESTful Rails apps I'm trying to make talk to each other. Both are written in Rails 3 (beta3 at the moment). The requests to the service will require the use an api key which is just a param that needs to be on every request. I can't seem to find any information on how to do this.
You define the url the resource connects to via...
Hi guys,
I'm trying out Rails, and I've stumbled across an issue with my routing.
I have a controller named "Account" (singular), which should handle various settings for the currently logged in user.
class AccountController < ApplicationController
def index
end
def settings
end
def email_settings
end
end
H...
How do I add a custom route for a new resource in the Rails 3 routes?
I know how to do it for collections and members but this style doesn't seem to be working for new resources. Is this a bug or am I doing something wrong?
So these work:
collection do
get :wish
end
member do
get :wish
end
But this doesn't work:
new do
get ...
bash-3.2# rails console
/opt/local/lib/ruby1.9/1.9.1/irb/completion.rb:9:in `require': dlopen(/opt/local/lib/ruby1.9/1.9.1/i386-darwin10/readline.bundle, 9): Library not loaded: /opt/local/lib/libncurses.5.dylib (LoadError)
Referenced from: /opt/local/lib/ruby1.9/1.9.1/i386-darwin10/readline.bundle
Reason: no suitable image found. Di...
Hi,
I have this nice class ErrorFormBuilder that allows me to add the error description near the corresponding field in the form view :
class ErrorFormBuilder < ActionView::Helpers::FormBuilder
#Adds error message directly inline to a form label
#Accepts all the options normall passed to form.label as well as:
# :hide_errors...
Guys,
I'm trying to understand the new arel engine in Rails 3 and I've got a question.
I've got two models, User and Task
class User < ActiveRecord::Base
has_many :tasks
end
class Task < ActiveRecord::Base
belongs_to :user
end
here is my routes to imply the relation:
resources :users do
resources :tasks
end
and here is my ...
Re-factoring dbase to support many:many:many. At the second and third levels we need to preserve end-user 'mapping' or aligning of data from different sources, e.g.
Order 17
FirstpartyOrderID => aha
LineItem_for_BigShinyThingy => AA-1 # maps to 77-a
LineItem_for_BigShinyThingy => AA-2 # maps to 77-b, 77-c
LineItem_for_LittleWi...
Before I begin, I am using Ruby on Rails and the Devise gem for user authentication.
Hi, I was doing some research about account security and I found a blog post about the topic awhile ago but I can no longer find it again. I read something about when making a login system you should have 1 model for User, this contains a user's usernam...
Hi,
On this article http://www.themodestrubyist.com/2010/03/16/rails-3-plugins---part-3---rake-tasks-generators-initializers-oh-my/ we can see the following codes which allow to invoke a migration file:
class ActsAsTaggableOnMigrationGenerator < Rails::Generators::Base
invoke "migration", %(add_fields_to_tags name:string label:string...
I have an ActiveRecord model class Foo that has_many Bar. I want to clone a Foo (to get duplicates of most of its attributes) and then modify its Bar instances.
This is a problem because cloned ActiveRecord instances share the same associated array; changes to one affect the other.
f1 = Foo.new
b = Bar.new
f1.bars << b
f2 = f1.clone
f2...
I have a controller called 'exposures' which I created automatically with the script/generate scaffold call. The scaffold pages work fine. I created a custom action called 'test' in the exposures controller. When I try to call the page (http://127.0.0.1:3000/exposures/test/1) I get a blank, white screen with no text at all in the sour...
I am using rails 3.0.0.beta3 and I am trying to implement form with nested attributes using :accepts_nested_attributes_for.
My form is nested to three levels: Survey >> Question >> Answer.
Survey has_many Questions, and Question has many Answers.
Inside the Survey model, there is
:accepts_nested_attributes_for :questions
and inside...
I am struggling with time zone support in Rails 3 beta and I would like to know if it is a bug or if I am doing something wrong. He is the problem:
> Time.zone = 'Madrid' # it is GMT+2
=> "Madrid"
> c = Comment.new
=> #<Comment id: nil, title: "", pub_at: nil>
> c.pub_at = Time.zone.parse('10:00:00')
=> Mon, 31 May 2010 10:00:00 C...
Hi.
I have a model of a club where I want to model the two entities Meeting and Member.
There are actually two many-to-many relationships between these entities though, as for any meeting a Member can either be a Speaker or a Guest. Now I am an OO thinker, so would normally just create the two classes and each one would just have two a...