ruby-on-rails

stubbing factory_girl + rspec methods and attributes

I'm using factory_girl + rspec on Rails 2-3-stable: Test: context "test" do before(:each) do @profile.stub!(:lastfm_enabled?).and_return(true) end it "should be able to scrobble if true" do @profile.update_attribute(:lastfm_scrobbling, true) @profile.lastfm_scrobbling_enabled?.should be_true...

Building my own game server for a turn-based multiplayer iPhone Game.

From the Game Kit Programming Guide... Multiplayer allows players interested in playing an online multiplayer game to discover each other and be connected into a match. Depending on your needs, your application can have either use Game Kit to connect all the participants together, or have Game Kit deliver a list of play...

Regex: How do you capture one group among multiple groups using regex? (in ruby)

I have two groups of text: firstgroup (some content) endgroup secondgroup (some content) endgroup I'm trying to just capture the first group (not the second group). I'm using this regular expression: firstgroup(.|\n)*endgroup For some reason, that regular expressions selects both first group and second group (probably because it ...

Where/How to code Constants in Rails 3 Application

I am interested in doing this the "Rails Way" on a new application. I would also like to refer to constants in some sort of context to make the code more readable. I have an application where a user can request access to another users's data set. This AccessRequest can have one of the following statuses: Review Denied Approved I can s...

nested model form and update_attributes

hi, I have a nested-model form with a one-to-many relationship between a class Project and class TeamMember, and in the controller, an update function like : @project = Project.find(params[:id]) @project.update_attributes(params[:project]) Now, I'd like to set some fields that are not set in the form for some of the t...

Find set that belongs_to another set

I'm sure there's an easy answer for this, but not sure how to word it to search for it. Given that articles belong to users, if I have a set of three different users, how can I access all of the articles written by any of those users with one query? ...

problem to rspec update action using rails 3

I'm facing a problem with rspec and controllers i'm spec'ing an update action, so to do it i call the following code: put :update, :id => "1", :ntp => {:name=>'myservah'} My controller has the following code: def update if @ntp.update_attributes(params[:ntp]) flash.now[:notice] = "Successfully updated ntp." else flash.now[:err...

IP Geocoding in Rails 3

I'm looking for a working gem/plugin for rails3 that does IP geocoding, and ideally, distance calculations. geokit seems to be a popular choice, but it doesn't support rails3 yet. ...

Client Application Communication with Application Server

We're creating a client-server model that communicates with an application server (Java clients, RoR server). We have a few options for the actual data that is going to be communicated: XML Communication that actually paints the client's screen (a la web-browser) Communicating just data/permissions/etc. through XML (Entire UI is held ...

Rails Serialized Data Validations

I have a field that is serialized to YAML through the default AR behavior. It is currently in an Array of Hashes for examples: [{'name' => 'hi', 'url' => 'bye'}, {'name' => 'hi', 'url' => 'bye'}, {'name' => 'hi', 'url' => 'bye'}] Is there a way I can use some basic AR validations on some of these fields? ...

Overriding active record model attributes only in the view.

I have an object called human and that object has a field called job. I want users to be able to add their own jobs (which will obviously be added in their own language) but I want to have any job that is a default in the database to be translated when someone does a Human.job, can rails translate the default if it is in the view but not...

having trouble passing formbuilder using remote_function with nested_attributes_for

Hey all I am having trouble updating a partial that contains a nested_attributes_for form with AJAX. My application needs to load a new section of the form based on the event type chosen in the main form. The fields associated with each type are stored in a database table. At the moment, when I select an event type, the id of the even...

Rails: How to build a url with redirect_to and routes.rb?

In my rails project i wanna use urls like this mysite.com/controller/title/action instead mysite.com/controller/id/action How can i now build a redirect to it, with the following line redirect_to :action => "show" it redirects to the id version, how do i have to customize the line to redirect to the url with the title? ...

What is a good Ruby on Rails forum that can easily integrated to an existing application?

What is a good, open source RoR 3 forum that can easily integrated to an existing application? Optional features: OpenID support Haml/SCSS templates Support for smilies, YouTube, images, etc I'm probably going to change it alot, and I'm still pretty weak in Ruby, so clean, commented code with good practices would be great. Thanks :)...

How can I test a view of product detail information in Cucumber?

I have an application with a product detail page. On that page the user can see prices, descriptions, specifications, all pretty standard stuff. But I want to test this view in Cucumber. Right now I use factories to generate product identifiers and leave everything else blank. If I add defaults to the factories, then check for those sam...

no such file to load -- .bundle/environment

I installed integrity app these days. and found some issues. I follow this. $ gem install bundler $ git clone git://github.com/integrity/integrity $ cd integrity $ git checkout -b deploy v22 $ bundle install $ bundle lock $ rake db at the end steps, I can't find and folders named ".bundle" in the integrity folder. an...

Difference between fields_for syntax

Is there any difference between: <%= event_form.fields_for :client, @client do |client| %> and <%= fields_for @event, :client, @client do |client| %> The parent form looks like this: <% form_for @event do |event_form| %> ...

Intermittent RingNotFound error all processes running locally

(Sorry about duplication of question. I put it in the wrong account at first) Am running a rails application which launches a series of relatively long running scripts using delayed_job and Rinda to farm out the work. At the moment am using a single delayed_job process (rake jobs:work, as am stuck on Windows), a ring server process ...

Rails - search records by group

Hi, I would like to construct a search query that groups the records by their 'tag' attribute, and finds a certain number of records for each tag group. My 'place' table is as follows: | ID | name | geom | rating_av | tag | There are four different tags that a place can be assigned - "city", "food", "hotel" and "attraction". I would ...

file upload with attachment_fu.

Right now i am storing files inside public directory in my application. I want to upload file to specific path like http://uploadfacility.com. I have a login and password for that specific path. http://uploadfacility.com/test?username=test1&amp;password=test1 How may i store files to specific path outside my application. I need to ...