This question is related to this other question:
http://stackoverflow.com/questions/2003732/change-rails-text-field-form-builder-type
I have a JQuery Tools Range in my form, and making it work requires that the input field be of the type "date". Rails doesn't easily allow me to do this so I've used a manual tag as follows:
<% form_for ...
I'm using a inherited controller for an abstracted class. I'm trying to avoid overriding actions within all of the descendant controllers. How could I find out the name of the key where the array of form values is living? For example:
The master class currently uses this to update rows
if @parent.update_attributes(params[:parent])
...
I've just inherited a website built with Ruby on Rails. I have never used the language before.
One thing I wanted to know is about Gems - my host only supports a few. I figure a Gem is like a library with PHP - for example, the mysql library is compiled with most PHP packages.
So I was wondering, does the following short code sample re...
I have a piece of code that checks that a survey response picked by user to a survey question is in fact one of valid choices:
Question.find_by_id(question_id).question_choices.all(:select => 'id').map {|x| x.id}.include?(user_choice_id)
Is there an easier way?
Thanks!
...
I'm working on a messy form which among other things has to manage a section with two-level nesting. It's almost working, but there's a snag and the only thing I can see that's different from other deeply-nested forms that work is that there's a belongs_to relationship rather than has_many. Here are the models:
Event
has_many :company...
I am using jqGrid and I don't want the grid to autoload.
I only want the grid to load once a user enters filter criteria.
Any advice?
...
I'm building a Rails app that needs some data visualization. What is a good library to learn? (If it matters, I don't have much web/javascript experience, but I'm starting to learn.)
I've been dabbling around with Protovis... But, well, I don't understand what all the hype is. It seems quite long and painful even to create just a simple...
How can I render a show action on certain conditions?
def show
@post = Post.find_approved
if @post.approved
approved = true
end
respond_to do |format|
# I only want to render show.html.erb if approved is true if not I would like to redirect the user back to where he came from
end
end
...
I'm new to Rails, and have been learning with Rails 3 on a side project. There are times when I want to write some code that does not belong in my models or in my controllers - concerns that are related to a model and/or controller, but i don't want to clutter up either of them with the implementation details of what i am writing.
For e...
Ok guys, so I'm making a scheduler.
So I have two tables so far,
Shows with "title:string" and "description:text" and I also have
ShowTime; with "show_id:integer", "day:string", and "show_time:time".
I did the has_many, and belongs_to, I honestly do not know where to go from here on,
I want a user to be able to add the times when cr...
Hey, I need to make a HTTP POST request with an array of NSDictionary objects.
When I do this, however, I notice on the server side that the NSDictionary object does not get deserialized to a hash. It gets deserialized to a string - which is not what i want.
This is how I send the parameter from the client (IPhone) side:
ASIFormDataR...
New to rails and I have what I think is a basic question.
In an admin view, there will be varying operations done on different data models. I have a layout "admin" which has various tabs the user clicks to load forms to edit various sets of data.
Should the controller for everything that can be edited in this view be in admin_control...
The Getting Started Rails Guide kind of glosses over this part since it doesn't implement the "new" action of the Comments controller. In my application, I have a book model that has many chapters:
class Book < ActiveRecord::Base
has_many :chapters
end
class Chapter < ActiveRecord::Base
belongs_to :book
end
In my routes file:
re...
I have a route that currently looks like this:
map.resources :regions, :collection => {:select_for_payroll => :get}, has_one => :payroll
How can I make the :select_for_payroll take both GET and POST?
Many thanks!
MrM
...
I want to create a system for users to comment on posts where comments can also have replies. Since I can't do a self-referential HABTM relationship, I did some research and saw that I should be going about it in this manner:
Post
has_many :comments
end
Comment
belongs_to :user
belongs_to :post
has_many :replies, :class_name =...
Hi i am using Ruby on rails. I am developing application where users can import their blogposts from wordpress , blogger and may be typepad into my site. can any one guide me how can i do it. Even if it's not a ROR solution do give me some ideas. I tried using Gdata api for blogger but that just gave me the link to post.
...
I have the following code which I need to update...
<% @users.each do |user| %>
<tr>
<td><%= link_to user.fname, user %></td>
</tr>
<% end %>
I want to learn how to update that so instead of just showing the fname, it shows fname + lname
so for a record like James Bond, it shows james bond and links it to the user in Rails.
...
How scalable is memcache in an enviornment where a cache is potentially getting expired every second. In fact, my question is not just about scalability of memcached but about situations where a model is continuously changing and the best way to scale that type of environment. One might say, why cache if the cache is getting expired ever...
The question is just above the last code snippet. Thank you.
(environment details are the end )
posts_controller.rb
class PostsController < ApplicationController
def create
@post = Post.new(params[:post])
respond_to do |format|
format.xml { render :xml => @post.to_xml(:include => [ :assets])}
end
end
posts.rb
class P...
Relating to my last question here: http://stackoverflow.com/questions/3740724/rails-finding-all-associated-objects-to-a-parent-object
Is it possible to sort multiple separate child objects in Rails by creation date, and then list them? Using the previous example I have a resume with two different has_many child objects, I would like to ...