In my application, users pick train stations from an autocompleting text field. Since there aren't many train stations (~100), I'd prefer for the field to autocomplete based on the contents of a client-side array rather than querying the server each time the user types a character (the goal is to make the autocomplete more responsive).
...
I'm considering shifting from PHP to Rails. Does an average web host support the Ruby language and everything that Rails needs? Does a normal Rails app using MySQL or does it handle data differently? And is it as "easy" to get an app up and running, as PHP?
...
I hope my question is understandable, else I'm glad to clarify.
We have this sport event coming up, and I have the pleasure to register the people. :)
Facts:
one can have a team of 5-10 persons.
Need to know the order in which the people start.
Need to know who the team leader is.
I did a form in the following style:
o [____Write...
Best way to load seed data? I have an Author table that is tightly coupled with a Users table. I also have migrations to alter both of these tables. I want to add a default admin user but I want to make sure that both tables are created and all migrations have run for these tables before my CreateDefaultAdmin (or whatever) migration runs...
Is there a gem/plugin for defining an API in Rails?
I know you can have "RESTful routes" and render to different formats in controller actions, but I'm looking for a more all-around solution, including but not limited to the following:
I would like to declare which models to expose (arbitrary resources could also be declared, but conve...
In Rails, the closest I've seen to Django Signals are Observers. The problem with them is that they're restricted to triggering callbacks on hardcoded events related to a model's lifecycle.
Django signals can be created anywhere, triggered anywhere and handled anywhere. The model lifecycle callbacks are just regular signals that happen ...
Hi,
I have a list view in my RoR web app. The view is a result of a scaffold operation.
I want to add a button that will refresh the page. I prefer not to use javascript for this one, is there another way?
Creating a button via button_to or form_tag ends up adding a new blank row in the database when it is clicked.
Thanks!
Shay.
...
Hi,
I'd like to generate unique, anonymous usernames when creating an instance of my User model. Ideally, it would be set by default if I don't specify any username.
So for example when I do User.create!() I'd like to have the username column set to 'anonymous123', where 123 is a unique number taken from a sequence (the value of the i...
An external web service is sending json or xml towards my app. What would be the best way to consume this data? Is there a built-in library in Rails or Ruby to do this or do I need to use a gem for this?
...
I have a controller action which could benefit from caching. However, when I turn on action caching via the usual:
caches_action :myaction, :expires_in=>15.minutes
...caching doesn't get invoked. It looks like this is because the action is invoked using an HTTP POST. For similar actions invoked using HTTP GET, caching works fine.
I...
Just wondering -- how do you know when to add map.resources for a particular model? All of them? The ones you want to be accessible by a public API?
Thanks.
...
if I do this:
curl -X POST -H 'Content-type: application/xml' -d '<person>...</person>' 'http://0.0.0.0:3000/people/12?_method=PUT'
I get "Only get, put, and delete requests are allowed." Why? Rails 2.3.2
...
I just installed Ruby Enterprise Edition and Passenger on an Ubuntu Hardy 8.04 VPS. As far as I'm aware, the installation was successful. My Rails application is accessible and on the whole, works fine. However, the part of my application where users can post comments using AJAX doesn't work. My Comment model has a setter method for the ...
I'm building a simple chat app with Rails. when a user types in a url, I want it to be output as an html link (ie, "url").
I was wondering if there is any library or well known way to do this in Ruby. If not, I've got some decent regex sample code to work with...
...
#!/opt/ruby_ee/bin
require 'rubygems'
require 'twitter'
require 'net/http'
require 'uri'
require 'httparty'
module FbTweet
def FbTweet.tweet(url)
bitly_url = Bitly.shorten(url)
httpauth = Twitter::HTTPAuth.new('username', 'password')
base = Twitter::Base.new(httpauth)
base.update("Testing to port this into rails plug...
I have four tables: jp_properties, cn_properties, jp_dictionaries and cn_dictioanries.
And every jp_property belongs to a jp_dictionary with foreign key "dictionary_id" in table.
Similarly, every cn_property belongs to a cn_dictionary with foreign key "dictionary_id" in table too.
Since there are a lot of same functions in both proper...
I'm a little stuck on using Prawn/Prawnto to generate PDF documents. The Prawn documentation has helped some, but the Prawnto documentation is seemingly offline these days.
I am trying to find a way to space text cells based on the previous cell's height. Prawn has the methods to do this -- no problem, but the return value from doing ...
I have a module like this:
module Controller
module LocaleModels
def self.included(base)
base.send :include, InstanceMethods
end
module InstanceMethods
def locale_Lexeme; constantize_model('Lexeme') end
def locale_Synthetic; constantize_model('Synthetic') end
def locale_Property; constantize_model(...
I have recently begun the process of trying to learn Ruby/Rails and have been making my way through Agile Web Development with Rails (3rd Ed.). While the content of the book is great I really wish I had either a cheatsheet or a checklist of some sort that describes the steps one should take in order to create an application, and the prop...
I have an action which I cache using
caches_action :my_action, :expires_in=>1.hours
and also set the expires headers in the action itself using
def my_action
...
expires_in 1.hours
send_data(...,:disposition => 'inline',:type => 'image/png',:filename => params[:title]+".png")
end
However, when I look at the cache control r...