Hi there,
I've coded the following spec:
it "should call user.invite_friend" do
user = mock_model(User, :id => 1)
other_user = mock_model(User, :id => 2)
User.stub!(:find).with(user.id).and_return(user)
User.stub!(:find).with(other_user.id).and_return(other_user)
user.should_receive(:invite_friend).with(other_us...
Hey all,
I'm trying to add authorization to a rather large app that already exists, but I have to obfuscate the details a bit.
Here's the background:
In our app we have a number or roles that are hierarchical, roughly like this:
BasicUser -> SuperUser -> Admin -> SuperAdmin
For authorization each User model instance has an attribu...
Hello.
I was wondering if there is the best practice on where to store global settings in a rails app. What I mean by that is i.e: I have a few globals defined that may change, but not likely and it seems inappropriate to store them in DB since they are used so much. For instance I have SYSTEM_EMAIL & SYSTEM_EMAIL_SIGNATURE & SYSTEM_STO...
Does someone know if there is a way to get the raw relevance or similarity score between a query and a result when using sphinx in general or thinking-sphinx as a wrapper? Any help is greatly appreciated.
...
Hello, I have implemented Authlogic. I believe that this isn't an authlogic specific quesetion. Assume that I have a User model and each User has a column in the database called "login".
Upon creating a user, the login column is populated. However, I don't want the user to be able to change their login once they set it.
Currently, I h...
I have a loop as follows:
<% for email in @campaign.emails%>
<strong>Email: </strong><%=h email.title %> sent after <%=h email.days %> days </br>
<% end %>
But actually I want it sorted by the email.days value when it displays to the screen.
How do I do that?
...
In one of my project with some existing code, some code is covered by _test.rb file, other is by _spec.rb and we introduced .feature
It became a nice mixture of stuff to check.
I am stumped how to run .feature, _spec.rb and _test.rb for red-green cycles.
...
In one of my model's I'm using some meta programming to dynamically define some methods. I'd like to test this; thus, I need a compact way to assert my model has a readable/writable attribute with a certain name. Ideas?
I'm using shoulda for unit testing if it makes a difference.
...
I recently cleared out all of my ruby install and installed form sources using the instructions at hivelogic
I have have been able to install a few gems, but most of the time, "sudo gem install rails"
hangs. I've added the -V flag, and it just seems to hang, I don't get any error. And the process can not be killed. I can only reboot...
i've created a select button with 3 option
<%= f.label :prioridad %><br/>
<%= f.select :prioridad, options_for_select([['Alta', 1], ['Medio', 2], ['Baja', 3]]) %>
The value gets inserted to the DataBase but when i display it i see the number op the option selected (which is correct).
What i would like to know is how i can change tha...
I'm submitting to a rails webservice the following message:
xmlPostData = "<message>
<message-text>" + MESSAGE_WITH_XML + "</message-text>
<name>" + subject + "</name>
<f1>" + toPhone + "</f1>
<f2>" + fromPhone + "</f2>
</message>";
The problem...
Ran my units tests this morning and I get this message. How do I get and install the native driver on osx?
The DL driver for sqlite3-ruby is deprecated and will be removed
in a future release. Please update your installation to use the
Native driver.
...
In rails, when saving an active_record object, its associated objects will be saved as well. But has_one and has_many association have different order in saving objects.
I have three simplified models:
class Team < ActiveRecord::Base
has_many :players
has_one :coach
end
class Player < ActiveRecord::Base
belongs_to :team
valid...
I can't seem to grasp the Rails routing just yet. I want to be able to link the site to, for example, ...com/store/xbox360/Mass Effect 2 (which is /store(my controller)/:system/:title).
I have the database entries that include the :system and :title variables (?). How would I route these to show up and filter these entries? Or is this ...
I'd like to use Rails 2.2.2 for one project and Rails 2.3.2 for another. Both are installed.
What is rails _2.2.2_ --version supposed to do? I've read that it makes 2.2.2 the working version -- that is, the version that will be used from that point on. But when I check rails --version, I get Rails 2.3.2. So, I also want to know what ra...
I have a sql to get data form mysql their I used dateformat to convert date required format
Here is the sql
SELECT
m.id,
m.subject,
m.body,
m.read,
m.hide,
m.thread_id,
DATE_FORMAT(m.sent_date, '%d-%b-%Y') sent_date,
u.username to_name
FROM
messages m,
users u
WHERE
u.school_id = m.school_id AND
u.id = m.to_user_id AND
...
I feel this should be very simple but my brain is short-circuiting on it. If I have an object representing the current user, and want to query for all users except the current user, how can I do this, taking into account that the current user can sometimes be nil?
This is what I am doing right now:
def index
@users = User.all
@user...
Hi-
I'm attempting to get my first "hello world" rails example going using the rails' getting started guide on my OSX 10.6.3 box.
When I go to execute the first rake db:create command (I'm using mysql) I get:
simon@/Users/simon/source/rails/blog/config: rake db:create (in /Users/simon/source/rails/blog) Couldn't create database for ...
Hi All,
In my next rails project I want to use liquid pages (so that my graphic designer can do his stuff without bothering be :D) By my question is
will i be able to use
render_component and render :partial commands inside my liquid layout. If possible how
thanks in advance
cheers,
sameera
...
I'm testing out a piece of code to ping a bunch of websites I own on a regular basis, to make sure they're up.
I'm using rails and so far I have this hideous test action that I'm using to try it out (see below).
The problem though, is that sometimes it works, and other times it won't ... sometimes it runs through the code just fine, o...