ruby-on-rails

Ruby on Rails with Repository Pattern?

After working with ASP.Net MVC, it has me thinking about Rails. I worked with Rails prior, but am a little rusty. ASP.Net MVC tutorials recomment hiding data layer implementation with the repository pattern. This allows easiesr Dependency Injection for Unit Testing, and nice decoupling of the controller from the model implementation. ...

Methods for limiting the Rails render format to html

I have a Rails 2.1.2 site that only has html templates e.g. jobs.html.erb, so when I request a restful resource: www.mysite.com/jobs/1 It renders my job in html, however, if I request: www.mysite.com/jobs/1.xml I get the error: Template is missing Missing template jobs/show.xml.erb in view path c:/workspace/mysite/app...

(Rails) Assert_Select's Annoying Warnings

Does anyone know how to make assert_select not output all those nasty html warnings during a rake test? You know, like this stuff: .ignoring attempt to close body with div opened at byte 1036, line 5 closed at byte 5342, line 42 attributes at open: {"class"=>"inner02"} text around open: "</script>\r\t</head>\r\t<body class=\"inner02" te...

Does Rails 2.0 do IPv6 well?

I'm using mongrel + apache 2.2 + mod_proxy_balancer. apache2.2 is IPv6 well http://httpd.apache.org/docs/2.2/en/bind.html#ipv6 Does Mongrel do IPv6 well? Platform:RHEL ruby:1.8.6 /actionpack-2.0.5/lib/action_controller/request.rb which is worried about the particularly . ...

Deploying a Django Opensource Application with dependencies

I'm working with a friend on a web application we'd like to distribute and we're working in Django. I'd like to make sure deployment is as easy as possible for potential users. It seems that Django uses shared installed libraries alot and I'd like for folks to just need to download our latest version, unzip, edit a config file or two a...

Association involving multiple tables

Hi guys, I have a data structure similar to the following picture. Table A has_many Table C through Table B; and Table C has_many Table E through Table D In order to make Table A has an association to Table E so that I can do a object_a.has_many_object_e, and having to meet the restrictions below: Adding foreign keys to any table is...

How to filter In ActionController?

Hello All,, I have problem in my controller page. Btw i want to execute localhost:3000/article/donat?author_id=4, this mean i want to get on view only article with author_id = 4 i have tried type code like this. def donat @title = "All blog entries" if params[:author_id] == :author_id @articles = Article.published.find_b...

nested attributes overwrite related model

I have a new action in my controller that I'm passing parameters into so the form for my new object will be filled out with the values from the record the user is duplicating, specifcally this gives the user the opportunity to 'edit' the new content before submitting it. like this: def new @parent = Recipe.find(params[:parent_id]) ...

adyen implementation

hi...i m new to ruby...i m finding it difficult to use adyen 0.2.1 for payment system implementation through a merchant website what i have developed...may anyone help me how shall i start getting users directed to adyen for payment, when they already have selected some product to purchase... ur help shall be appreciated from the bottom ...

Rails routing with date and has many

I've got the following setup: map.resources :articles map.resources :users, :has_many => [:articles] Which is fine as I can do /users/2/articles to get a list of articles by a given user. I also have a route setup to do: map.connect 'articles/month/:month/:year', :controller => 'articles', :action => 'index' Which works for find...

Modularizing Rails applications

I'm looking for a way to modularize Rails applications. As I've seen there is no built-in way of accomplishing it. I've found different plugins/core hacks but I feel untrusted about the way they work and their maturity. Do you have any experience on this? So far I found this ones: Desert: http://github.com/pivotal/desert Rails engine...

Rails threading - multiple tasks

Hi I am trying to run multiple tasks, each task access the database, and I am trying to run the tasks into separate execution wires. I played around, tried allow_concurrency which I have set to true, or config.thread_safe! but it I get un-deterministic errors, for example sometimes a class is missing, or a constant ... here is some c...

how to insert into multiple tables in rails

Hi all, i am trying to insert into multiple tables using rails.. i have a table called users and services. when i create a user the user details should go into users and a service name and userid should go into services table. Any help would be greatly appriciated. Thanks. ...

What's the best practice for setting up associations with factory_girl in cucumber?

I normally use this step to set up records with factory_girl: Given /^the following (.+) records?:$/ do |factory, table| table.hashes.each do |hash| Factory(factory, hash) end end And here's my work-around when setting up associations: Given the following group record: | id | name | | 1 | foo | And the following item re...

Rails Validation for users email - only want it to validate when a user signs up or updates email address.

I have a User model with the usual attributes such as email and hashed_password etc. I want to write a validation that checks for the presence of an email address but only when 1) there isn't one stored in the database for this object (i.e. this is a new user signing up) 2) the user is trying to update their email address. My current...

How do I integrate SAML into my Rails Application?

I have a rails app that is currently an affiliate site with my customer's SSO Identity Provider. Currently it uses the CA SiteMinder Affiliate Agent, which is an apache module. The underlying SSO architecture is abstracted away and my Rails app only has to parse and HTTP Header to receive the values from my customer's Identity Server. ...

Facebox_Render + Form Redirection

Hey All, I'm currently using the facebox_render plugin to create modal popups in my rails app. What I'm not sure how to do though is as follows: If i have a form that is rendered to the facebox, when that form is submitted (update route in my controller), how do I redirect the renderer BACK to the current facebox. Essentially, if I wa...

Rails named_scope syntax error

I have a database of sports teams that I am displaying in tables/standings. The relevant code involves two models, Tableposition and Draw, which are associated in a has_one relationship. The following static named scope declaration works perfectly: class Tableposition < ActiveRecord::Base belongs_to :draw named_scope :grouptable, :i...

RESTful Archiving in Rails.

I have a blog function in my rails app. Currently I only have 4 bloggers on the site and have a (pretty unsatisfied) way of routing them like this: map.scarlet '/scarlet.:format', :controller => 'blogs', :action => 'show', :id => 'scarlet' map.alba '/andreasweinas.:format', :controller => 'blogs', :action => 'show', :id => 'alba' So t...

Convert XML into a Dataset

I'm trying to convert an XML document into a dataset that I can import into a database (like SQLite or MySQL) that I can query from. It's an XML file that holds most of the stuff in attributes. This is part of a Rails project so I'm very inclined to use Ruby (and that's the language I'm most comfortable with at the moment). I'm not sur...