Let's say I have the following model:
Person <AR
def name
[self.first_name,self.middle_name,self.last_name].select{|n| n.present?}.join(' ')
end
end
How could I do a search on the virtual attribute with searchlogic, something like:
Person.search.name_like 'foo'
Of courese I could construct a large statement like:
Person.search...
I am not really understand how's the nested attributes work in Rails.
I have 2 models, Accounts and Users. Accounts has_many Users. When a new user filled in the form, Rails reported
User(#2164802740) expected, got Array(#2148376200)
Is that Rails cannot read the nested attributes from the form? How can I fix it? How can I save the d...
Hi,
I'm trying to switch one of my websites into en-UK so that I get the correct date and currency formats etc...
I have found this yaml file:
http://github.com/mattetti/globalite/blob/master/lang/rails/en-UK.yml
Any ideas if there is a better one to use?
I also checked here but could not see it:
http://github.com/svenfuchs/rails-i...
Hi all,
the code below explains the problem in detail
#this returns error Net::HTTPBadResponse
url = URI.parse('https://sitename.com')
response = Net::HTTP.start(url.host, url.port) {|http|
http.get('/remote/register_device')
}
#this works
url = URI.parse('http://sitename.com')
response = Net::HTT...
Hi
I know from vim the % to move to associated ( ), { }, [ ]. How can I do that in textmate?
...
Hello,
is it possible to send notification emails when passenger error occurs? Something similar to the email sending by exception notifier when there is an error in Rails app.
I wonder because now we have no way to find out if someone hits an unexpected app spawner or other error (like memory limit etc.).
Thank you!
...
I have been given a project of editing a website which is coded in RoR.
However, the changes which i make in the view file is not visible immediately after a hard refresh but after 15-20 mins, the changes reflect. I am guessing this has something to do with the RoR caching system.
Can someone please help me out ? The changes i made are...
Hey,
I am creating a site in Ruby on Rails, I have two models a User model and a Transaction model.
These models both belong to an account so they both have a field called account_id
I am trying to setup a association between them like so:
class User < ActiveRecord::Base
belongs_to :account
has_many :transactions
end
class Trans...
As the title says, how can i generate the default mongoid.yml config file on Rail 2.3.5?
I try to use te ´rails generate mongoid:config´ command but it just generates a new app.
And also, i would like to use has_many in mongoid without embeding the associated model in the same field. I would like them to be in seperate fields and associ...
I've came into a problem while working with AR and polymorphic, here's the description,
class Base < ActiveRecord::Base; end
class Subscription < Base
set_table_name :subscriptions
has_many :posts, :as => :subscriptable
end
class Post < ActiveRecord::Base
belongs_to :subscriptable, :polymorphic => true
end
in the...
Hi, I have rails app which has a list of users. I have different relations between users, for example worked with, friend, preferred. When listing the users i have to decide if the current user can add a specific user to his friends.
-if current_user.can_request_friendship_with(user)
=add_to_friends(user)
-else
=re...
Hey,
I have a Ruby on Rails application setup like so:
User Model
has_and_belongs_to_many :roles
Role Model
has_many :transactions
has_and_belongs_to_many :users
Transaction Model
belongs_to :role
This means that a join table is used called roles_users and it also means that a user can only see the transactions that have been ...
Hi -
I need to see what page a request came from in my controller so I could be able to redirect back to it. For example, if I'm on a page showing a specific product (say /products/1) and it has a link to its vendor (/vendors/12), I want to be able to detect inside the vendors_controller that I came to that page from /products/1. Is th...
Here's my index action in the books controller: http://pastebin.com/XdtGRQKV
Here's the view for the action i just mentioned: http://pastebin.com/nQFy400m
Here's the result without being logged in: http://i.imgur.com/rQoiw.jpg
Here's the result when i'm logged in with the user 'admin': http://i.imgur.com/E1CUr.jpg
So the problem is t...
I'm a new ruby/rails user trying to get my mac set up for the first time with an existing rails project. The app runs fine when using mongrel, but it doesn't start properly when using Phusion Passenger.
The problem seems to be when loading the first model of the project. I'm speculating that there's a problem accessing my database, bu...
Hi!
I've got model A and model Attach. I'm editing my A form with nested attributes for :attaches. And when I am deleting all attaches from A via accepts_nested_attributes_for how can I get after_update/after_save callbacks for all of my nested models? Problem is that when I am executing callbacks in model A they are executed right AFTE...
Especially when you are using Searchlogic. It is kinda hard for me to guess what named scope to use to achieve what I need.
...
Hi Everyone,
I am working on getting multiple file uploads working for an model in my application, I have included the code below:
delivers_controller.rb
# POST /delivers
def create
@deliver = Deliver.new(params[:deliver])
process_file_uploads(@deliver)
if @deliver.save
flash[:notice] = 'Task was successfully created.'
...
how can I eliminate duplicate elements from an array of ruby objects using an attribute of the object to match identical objects.
with an array of basic types I can use a set..
eg.
array_list = [1, 3, 4 5, 6, 6]
array_list.to_set
=> [1, 2, 3, 4, 5, 6]
can I adapt this technique to work with object attributes?
thanks
...
I have two models, User and Account. Each user may have one account.
Creating an account for a user works fine. My problem is that when I try to update the account, the previous accounts user_id is nullified and a new account row is created with the user_id. I do not want this happening. I want to update the existing row with the chang...