ruby-on-rails

Why is Rails' asset cache not working for JS in the staging environment?

I have my CSS and JS set to cache in RAILS_ROOT/app/views/layouts/application.html.erb: <%= stylesheet_link_tag 'reset', ... 'layout', 'colors', :cache => 'cache/all' %> <%= javascript_include_tag 'jquery-1.3.2.min', ... 'application', :cache => 'cache/all' %> If I turn on caching in ...

Rails Cucumber Testing With a LDAP Server

I am trying to write some cucumber tests for my application that uses Authlogic for authentication, but actually stores users in a LDAP server. The application seems to work fine, but where I am running into trouble is writing tests for it (I know, I know, I should've wrote the tests first.) It's easy to have a test database where the d...

deploying with capistrano with remote git repo but without git running on production server

I have a remote git repository setup for centralized development within my team. However, the production server that we deploy our applications currently does not have git running on it. We want to use capistrano to deploy our applications how can we set up our deploy recipes to 'pull' from the remote git repositories when deploying? In...

Can i limit apache+passenger memory usage on server without swap space

Hi, i'm running a rails application with apache+passenger on virtual servers that do not have any swap space configured. The site gets decent amount of traffic with 200K+ daily requests and sometimes the whole system runs out of memory causing odd behaviour on whole system. The question is that is there any way to configure apache or p...

Even better support for HAML in Netbeans?

This plugin is pretty good, definitely better than plain-text.. but I'm longing for a little more. Code completion, the Netbeans code generator shortcuts, 'ri' integration for looking up documentation like the .erb files have.. Does anyone have some tricks, is there a different plugin for this type of functionality in Netbeans? Definit...

How are require, require_dependency and constants reloading related in Rails?

I need to write a plugin for a rails application which uses Engines. Since I have no Rails experience before, I read some documents and tutorial stuff. But Rails' class loading process lost me, feels like so much black magic behind. The basic question I'm having is how require and require_dependency are different? How can require_depe...

Ruby on Rails symbol validation

I have this model: class Story < ActiveRecord::Base validates_presence_of :name , :link end Where a validation for a form take place. But I want also to validate if the string "http" is included in the :link symbol. I can't do :link.include? because :link is symbol. How do I do that? My View is this: <% form_for :story do |f| %>...

Ruby on Rails User Management Engine/Framework? (with web pages)

Hi, There are quite a few post/recommendations re Rails authorization plugins. What I'm asking here however is whether there is a popular/good Ruby on Rails Engine (or framework) that includes the user interface pages as well (and controllers/models etc). So something one could integrate in (Engine) or use as a starting point that inc...

Proper way to find records for a certain foreign key

I have two Models called User and Membership. User has_many :memberships Membership belongs_to :user What is the proper way to modify MembershipsController's index method to set @memberships to all the memberships there are for the user "session[:user_id]"? I tried something like: @memberships = Membership.find(:all, :conditions => ["u...

Thinking Sphinx, associations are not working

I have a model: class Topic < ActiveRecord::Base define_index do indexes title, :sortable => true indexes body indexes tags(:name), :as => :tag_name end has_and_belongs_to_many :tags, :join_table => 'topic_tags', :order => 'tags.name asc' end When I run: rake ts:rebuild I get: sql_range_query: Unknown column...

How do I include the capistrano thinking sphinx tasks when using the gem

Im using the gem for thinking sphinx: sudo gem install freelancing-god-thinking-sphinx \ --source http://gems.github.com So: require 'vendor/plugins/thinking-sphinx/recipes/thinking_sphinx' Which is prescribed on the website does not work. How do I include the capistrano thinking sphinx tasks in my deploy.rb file when using th...

Rails plugin that autoselects mime-type for attachments in ActionMailer

I want to send multiple attachments but not declaring them just octet-stream doing it right now like this newsletter.attachments.each do |file| contend = File.new(file.path+"/"+file.filename, "r") attachment "application/octet-stream" do |a| a.body = contend.read a.filename = file.filename end unless file.blank? sinc...

What modeling technique/tool/diagram would you recommend for a rails/grails application?

I am interesting in a diagramming methodology that can capture user-interaction in a way that will incorporate the "screens" along with the "actions", and how those are driven by controllers,views and services. ...

Emulation of each_slice without block in ruby < 1.8.7

Hi! Im trying to test my rails applications javascript using jruby 1.3.1,celerity and culerity. The application itself runs under ruby 1.8.7 + phusion passenger (and runs fine, sans test :)) Everything installation-wise works fine but my app uses some_enumerable.each_slice(10) to split a larger array into smaller subarray with 10 elel...

Difficult to use ActiveMerchant in a project that does not use ActiveRecord as its ORM?

ActiveMerchant seems to be baked with AR in mind. I've come to this conclusion based on the fact that the purchase() method returns an ActiveRecord::Billing::Response object: Is this correct and, if so, does this mean it might be difficult to use ActiveMerchant in a project that uses a different Ruby ORM (Sequel/Datamapper)? ...

before_filter :require_owner

I have a number of resources (Trips, Schedules, etc) with actions that should be limited to just the resource's owner. How do you implement code with a #require_owner method defined in ApplicationController to achieve this? Ideally, the code will look up the inheritance chain for the owner so the before_filter will work on a :comment ...

DRY form partial for create and update

I have a _form.html.erb form partial which helps to DRY up my code but I need the form to have different labels depending on if I am creating a new user or updating an existing user. Here is my form partial. I don't need to show the eula checkbox during update and I also need to replace the "Create my account" submit button text to some...

Nested attributes and hidden_field_tag

Hi I have a form with several nested forms (only two level) and I need to pass hidden_fields on the form and then to the nested model. I can not seem to get the nested models to received the hidden form value. With the top level form I am using hidden_form_tag and it is working fine (although it seems like maybe I should be using jus...

How can I use a variable to access the fieldname of a ruby object in erb? ex. Model.task_#{variable}

I have a to-do list with 5 tasks that are stored on the same record. Todo.task_one, Todo.task_two, etc. What I would like to do is be able to loop through the fields like this total_tasks = ["one", "two", "three", "four", "five"] for tasks in total_tasks Todo.task_#{tasks} = "text here" end However, this doesn't work unless I use e...

Mutex for Rails Processes

When deploying Rails via Passenger or Mongrel you have multiple instances of the application running. What is the best practice or pattern to establish a mutex on shared resources such as a writing to a local file or to a remote file. I want to ensure two processes are not writing to the same resource at the same time. ...