ruby-on-rails

How to connect the localhost Rails site via Mobile (my samsung) locally?

I've my rails site that I'm developing on localhost Ubuntu and I've a mobile. My site runs in http://localhost:3000 Now I want to access this directly via my mobile browser not going through internet. Is there any way to access it via wifi or else way?? ...

Rails: display events with calendar_date_select

Hello, I'm trying to display events in calendar generated by calendar_date_select plugin for Rails. I have Concert model with datetime field date. Can I somehow throw in @concerts which equals Concert.all to calendar_date_select_tag to display links to make days where concert is clickable? I would like to stick to this helper cause I...

Dump queries made by ActiveRecord to file?

Is there an easy way to dump / write the queries performed by ActiveRecord into a file? I know that they are in the log, but without parsing that? How can I get the queries? ...

How to modify the default RoR behavior to AJAX CRUD?

I want a table to do CRUD, but I want it in an Ajax way, how can I modify the default RoR behavior, any suggestions on that? I tried comment these code in destroy method, but it don't work, it saw missing the destroy.erb: respond_to do |format| format.html { redirect_to(categories_url) } format.xml { head :ok } end ...

Ruby on Rails: How to gather values for child tables from a form?

Referencing question #2013421, I have the following RoR models: class Game < ActiveRecord::Base has_many :piles end class Pile < ActiveRecord::Base belongs_to :game end For the sake of argument, suppose Game has an attribute name, and Pile has an attribute type, both string. There are precisely 10 piles per game. I would like a ...

how can I connect netbeans(ruby on rails project) with source safe (Vss) ?

how can I connect netbeans(ruby on rails project) with source safe (Vss) ? ...

Elegant "select distinct" for collection_select

Hi, I am fairly new to RoR and hacking on a small application. In order to display existing values of some model column in a form, I currently do: <% form_for([@testbox, @testitem]) do |f| %> <%= f.label :sortkey %><br /> <%= f.collection_select :sortkey, Testitem.groups , :sortkey, :sortkey, {:include_blank => true} %> <% end %> ...

add a category field inside product form in rails

I have product and category models, what i want to do is to add a category field inside add new product form (i want it to update in ajax format) my form is something like this : <fieldset> <legend> <%= @form_title %> </legend> <%= error_messages_for 'theme' , :header_message => "موارد زیر دارای اشکال می باشند، لطفا...

How to process new children in before_update callback for activerecord nested attributes

I have a model object (let's say Parent) with a has_many association on another model object (Child). class Parent < ActiveRecord::Base has_many :children accepts_nested_attributes_for :children end class Child < ActiveRecord::Base belongs_to :parent end On Parent, I want to add code on the before_update callback to set ...

Another way to write: if some_variable && some_valiable.size == 2

Hi there, In Ruby & in RoR I oft find myself testing whether an object exists, then whether an object's properties match some criteria. Like so: if params[:id] && params[:id].size == 40 ...do stuff end Is there a more efficient way to do this? Something like: if params[:id].size == 40 rescue false but without using the rescue? ...

Link with Name Attibute in Rails

I was wondering about how i can do this in rails because i want something like <a href="requests/13#new">Comment!<a> anyone knows it? greetings ...

Custom validation of associated model

Hello, I have provider and patient models which both are belongs_to contact. On the provider and patient edit forms i use fields_for :contact to render associated contact fields. The problem is in that i want to use different validation rules for provider.contact and patient.contact objects, i.e. i want to validate presence of contact'...

Which is a better source control with NetBeans (Ruby on Rails), VSS or Subversion?

Which is better source control with NetBeans (Ruby on Rails), VSS or subversion? I want to use source control, so I want to know which is better for NetBeans (RoR). Visual Source safe or Subversion? ...

Rendering a Rails view to string for email

I'd like to send emails from a table every night at midnight, so I've created a model to track all communications to be sent. This Communication model stores who the letter is to, from, and the contents of the letter to be sent as html. The user enters a criteria to match for whom the letter is intended: state, country, favorite color,...

Tracking User Actions on Rails website

Hi, Users will each have a user profile, and he wants each user to know who has viewed their profile. The only way I can think of doing this involves doing a database INSERT every time someone views a profile page (probably using an Ajax call at the end of the page). This sounds like a massive performance issue, especially if the site...

How do you prevent flash[:notice] from being rendered twice when redirecting from ApplicationController

I have a simple method in the ApplicationController that, when called, may set a 'flash[:notice]' then redirect to the root_url. The problem is that even though that method is only called once, the root URL renders that flash[:notice] TWICE. Here's a the method (which is a before_filter used in other controllers, and is defined in the ...

checkbox with new render partial

Hello, I am trying to re render a page with a checkbox that has been selected prior to the render. With the result, I converted it to an integer. if I have the following code, how do I make the checkbox either checked or not check_box("price", "total", {:checked => @checkVal}) where @checkVal is my checked/not value (int) ...

Group and count in Rails

I know I've seen this before but I can't find anything now. I want to group a query by a certain column and be able to display how many are in each group. I got the first part down: @line_items = @project.line_items.all(:group => "device_id") This is for my line item index view, which is just a table displaying the line items. How...

Will enabling `mod_status` in apache slow my app down?

If I wanted to to monitor response time of my requests should I use Apache's mod_status or should I use Passenger's passenger-status monitoring tools? My concern is that enabling mod_status will slow my apps down, but I don't have anyway to compare since I need to run mod_status to benchmark the performance. By the way Passenger's pas...

How to force Jruby to use inbuilt Ruby 1.9 instead of Ruby 1.8 which is default?

I have developed a Ruby on Rails application and successfully deployed on Weblogic using Jruby and Warbler (which creates a war file based on the settings in config/warble.rb). I believe although Jruby comes with inbuilt Ruby 1.8 and 1.9, by default it uses 1.8 and I want to test the same rails application in Ruby 1.9 within JRuby as I...