I have a model Publication and a model Category in my Rails app. Both are connected with a has_and_belongs_to_many association.
Now I would like to search publications that match one or more categories. If more than one category is given they have all assigned to the publication. I want to specify the categories in a multiple select_bo...
I've got the following code for a search form, but how would I add an ID or a class to the submit button?
<% form_tag '/wine/search/', :method => 'get' do %>
<%= label_tag "Search" %>
<%= text_field_tag :search_string, params[:search_string] %>
<%= submit_tag "Go" %>
<% end %>
Thanks
...
Hello:
I have a note table with columns:
title :string
content :text
rating :integer
and a thinking_sphinx configuration:
define_index do
indexes :title, :sortable => true
indexes :content
end
Then I can search the notes and assign weights to title and content to define the order or the result:
Note.search "abc", :match_mode...
I'm doing maintenance work on an existing rails site and have run into a strange bug. There are a few different models involved here: Registrations, Business Categories, and Services. Registrations HABTM Business Categories and Services, each of which HABTM Registrations. The appropriate non-primary-keyed join tables exist for each of ...
Has anyone come across a web service or plugin/code/calculation for getting information on tides - namely high and low tide times?
I only need this information for one location (outside the US) but I need it on an ongoing basis so a web service that I can hit once a day or something would be ideal.
...
map.root :controller => "main", :action => "index"
is not redirecting the main controller to home page to localhost:3000
any suggestions?
...
Hey. I would like to upload a file and then parse it. Because parsing can take up to 10min I installed delayed_job plugin and called parsing function through send_later function. I have to mention that this is an AJAX app.
Imagine that you press an AJAX button that starts upload and after that the source is imported into the database. D...
Curious how one would go about calling a class method from inside an instance method of a module which is included by an active record class. For example I want both user and client models to share the nuts and bolts of password encryption.
# app/models
class User < ActiveRecord::Base
include Encrypt
end
class Client < ActiveRecord::...
I need to convert a Date object into a TimeWithZone object representing the beginning of that day in a given time zone.
The following approach works, but seems too convoluted as it requires me to convert the date to a string:
?> date = Date.parse("2010-02-17")
=> Wed, 17 Feb 2010
>> ActiveSupport::TimeZone['Eastern Time (US & Canada)']...
I am (finally) attempting to write some integration tests for my application (because every deploy is getting scarier). Since testing is a horribly documented feature of Rails, this was the best I could get going with shoulda.
class DeleteBusinessTest < ActionController::IntegrationTest
context "log skydiver in and" do
setup do...
I'm looking to retrieve the latest two posts from a Blogger.com account that belongs to me.
What is the best way of doing so using Ruby on Rails 2.3.5?
Thanks!
...
In the documentation concerning Fixtures (http://api.rubyonrails.org/classes/Fixtures.html) they provide the following example of using label references for associations:
### in pirates.yml
reginald:
name: Reginald the Pirate
monkey: george
### in monkeys.yml
george:
name: George the Monkey
pirate: reginald
So following their...
Im trying to eliminate two tables from my database. The tables are message_sort_options and per_page_options. These tables basically just have 5 records which are options a user can set as their preference in a preferences table. The preferences table has columns like sort_preferences and per_page_preference which both point to a record ...
I'm trying to perform an integration test via Watir and RSpec. So, I created a test file within /integration and wrote a test, which adds a test user into a base via factory_girl.
The problem is — I can't actually perform a login with my test user. The test I wrote looks as following:
...
before(:each)
@user = Factory(:user)
@brow...
Hi all,
I'm looking for the right messaging system for my needs. Can you help me ?
For now, there won't be a huge amount of data to process, but I don't want to be limited later ...
The machines are not just web servers, so the messaging tool should be lightweight, even if processing is not very speed.
When some data change on a serve...
Does anyone have any good resources on how to do this?
Basically, I'm working on a project (in Rails) where people can upload files. They might be big. I'd like to process them using delayed_job before sending them to S3. I'd also like to do this processing on a separate job queue server, rather than on the webserver itself. I'd rather ...
I'm currently building a semi-small ruby app for a project. The problem I'm currently facing is the following:
I want to be Able to fit the Article into the Categories. I've already accomplish this by having two models. An article model with a foreign key of category_id and my Category model with the name of the category. With a has_one...
I have certain initializing functions that I use to set up audit logging on the DB server side (ie, not rails) in PostgreSQL. At least one has to be issued (setting the current user) before inserting data into or updating any of the audited tables, or else the whole query will fail spectacularly.
I can easily call these every time befor...
Is it possible to do a redirect in the routes file of a Rails app?
Specifically, I'd like to forward /j/e to /javascripts/embed.js
Right now the only way I can think to do it is to create a j controller with an e method that redirects to that.
...
I have a model Post that has_many :tags
I want to do:
Post.create({:tags => ['tag1', 'tag2']})
How can I make that work?
...