so I want to do something like this:
, :order => "(products.name = 'Some Product' or products.name) desc", :order=>'distance'
has anyone done this before? I realize that I cant do it the way I have written, but hope it explains the order I want the orders to happen.
...
Can any one please tell me the syntax of using FQL in a rails application ?
I would like to use the code in my controller.
I have all the queries but need syntax to make it up and running.
Thank in advance ;)
...
There are a lot of role-based authorization plugins out there. They work great when you know in advance what the roles are going to be. For example, if I know I'm going to have administrators, super_users, and not_so_super_users.
What I really want is to be able to create custom roles and assign that role to a user. At this point, I am ...
I am creating an application with a search feature, and I would like have it set up similarly to Google or Twitter search, where there is a landing page with a search form at the root URL and then data from this form is passed through a query string, which forms the URL for the results page (for example: www.domain.com/search?query=my+se...
I've heard about javascript solutions, and accessorkeys...
Don't know either... but there seem to be mixed feelings about which to use.
I want standard key shortcuts for each OS (command for mac, ctrl for everything else)
any help / links / tutorials would be very appreciated.
...
HI
Is there a way i can add commas to a number like so:
num= 1234567
then becomes
num = 1,234,567
I would like to make this call in my helper i.e module
thanks
...
Rails 3...
I have a controller..
class OrdersController < ApplicationController
def index
@os_orders = OrlandoOrder.all
@ct_orders = ChicagoOrder.all
end
end
And then I have the two models defined...
class ChicagoOrder < Order
Order::ActiveRecord::Base.table_name_prefix = 'ct_schema.'
end
class OrlandoOrder < Order
...
Is there a way to run processes from rails script/console in the background?
I have a onetime lib script that will take two or so days to execute and I want to set this to run in the background.
Something like:
script/console
Then:
>> load 'script.rb' &
In the commandline I'd just do:
$ command &
I did find: http://backgroundrb...
I'm using rspec 1.3, and using rspec's mock_model to mock out some of the models in my controller tests. I create all the mocks in the before(:each) in the controller spec. I then run my model tests where I build real activerecord objects for setup in before(:each) instead of mocks. It seems that in my model tests, the model is still ...
I have a couple of rails relationships.
class Customer < ActiveRecord::Base
has_many :sites
end
class Site < ActiveRecord::Base
belongs_to :Customer
end
I want to be able to get a list of sites ordered by the long-name field of the customer and then the long-name field of the site, I want to use the list in a select element on a pa...
Each user has many roles; to find out whether a user has the "admin" role, we can use the has_role? method:
some_user.has_role?('admin')
Which is defined like this:
def has_role?(role_in_question)
roles.map(&:name).include?(role_in_question.to_s)
end
I'd like to be able to write some_user.has_role?('admin') as some_user.is_admin?,...
My application has 2 roles: Editor, and Admin. I want Editors to have some permissions, and Admins to have all editor permissions plus some other permissions.
Here is an excerpt from my ability.rb
class Ability
include CanCan::Ability
def initialize(user)
if user.is_admin?
can :edit, Post
end
if user.is_editor?
...
In my Rails application I am trying to use the acts_as_taggable_on_steroids plugin but it is falling short a little bit. I would like to add a second parameter to each tag that describes what it is tagging. Not the class, I understand that is recorded in the taggings join table. For example, if I were to tag an interview, I would give it...
Everyone loves to display Digg/Tweet/Like badges on their websites, and the Disqus Comment System is starting to take over.
The benefits of those systems from a developers perspective are:
You don't have to program the complex, fully-featured logic that those seemingly simple systems require.
You don't have to handle the ...
So I have the following migration - typical ratings table which captures ratings(value) for comments. I have some helper methods for primary-key(pk), foreign-key(fk), index(index) which is all fine.
So everything runs fine, but what i notice is that the foregn key on comment_id does not get created, even though this statement is not rep...
I'm writing a small web app for myself in Rails and I want it to use Last.fm's API. I'm incredibly new to web development in general, so I'm not sure where to even begin.
http://www.last.fm/api/rest
I'm not asking for a step-by-step tutorial or anything like that, but a nudge in the right direction would be awesome. Or even just a litt...
I have a number of objects which are associated together, and I'd like to layout some dashboards to show them off. For the sake of argument:
Publishing House - has many books
Book - has one author and is from one, and goes through many states
Publishing House Author - Wrote many
books
I'd like to get a dashboard that said:
How man...
I've got a fairly simple app at the moment, trying to learn rails 3 beta & mongodb.
I have a User and the User has messages.
When I try to create the User, I get an error
uninitialized constant Message
the error is traced back to the User model line 22 which is
has_many :posts, :dependent => :destroy
If I remove the :dependent...
How does rails get away with the following in an .erb file?
<%= yield :sidebar %>
<%= yield :other_bar %>
<%= yield :footer %>
How are they able to yield multiple times in the same context to different symbols? Is this some kind of rails magic?
I'm totally familiar with:
def some_method(arg1, arg2, &block)
yield(:block)
end
To m...
Is there a way to limit the number of instances of a rake task?
I have a rake task for reading emails that runs every 5 mins as a cron job.
Sometimes the rake tasks takes more than 5 mins to complete and another
rake task is launched before it finishes.
There are hacky workarounds to check ps -Af inside the rake file but I
am looking...