ruby-on-rails

Thinking Sphinx and acts_as_taggable_on plugin

Hi, I installed Sphinx and Thinking Sphinx for ruby on rails 2.3.2. When I search without conditions search works ok. Now, what I'd like to do is filter by tags, so, as I'm using the acts_as_taggable_on plugin, my Announcement model looks like this: class Announcement < ActiveRecord::Base acts_as_taggable_on :tags,:category defi...

Ruby gem already activated

How can I de-activate the newer version of cucumber, or get this to work with the earlier version? user$ rake features (in /Users/user/Project) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I "/Library/Ruby/Gems/1.8/gems/cucumber-0.6.1/lib:lib" "/Library/Ruby/Gems/1.8/gems/cucumber- 0.6.1/bin/cucumber" --form...

How do I run multiple instances of my Rails app?

You know, for load balancing, etc? I have a VPS and understand you can deploy and run multiple instances and have them share data with database session store and memcached and the like. What I have not been able to find is any information on how this is done? I am curious about multiple instances (two or three) on a single VPS and also ...

Simple quantity function problems, shopping cart

I just picked up Agile Web Development with Rails 3rd Ed., and I'm going thru the Depot Application chapters, I'm attempting to create a simple Edit quantity function, and delete function. I've had luck with the delete function but no luck with the edit quantity function. I'm going to provide a lot of information, so please don't feel ...

Prompt a user to login after he takes a certain action

One thing you can do on my rap lyric explanation site is "like" explanations (once you're logged in): I'd like to show the "Like" links to users who aren't logged in, and then, when a non-logged in user clicks "Like", show him a lightbox with a "Login or Register" form (like Digg / Reddit) What's the best way to accomplish this? C...

SMTP errors at sendig emails with ruby on rails

I've been trying to send some test newsletter using my gmail account as smtp, but when i tried to send to multiple recipients - ['emai@[email protected], [email protected]'] - in this case the first email address is incorrect - it gives me an error 555 - 5.5.2 Syntax error and the process stops without passing through the next email add...

What should my directory structure look like for user assets in a web application?

In my web application, each user will have a logo. I am pretty sure each user will also have a photo gallery in the future. What is the best way to set up a directory structure for managing user logos and possibly other assets such as photos? Also would be good to get people's opinions on what to store in the database. My application...

Thinking Sphinx - Search filter not working

Hi, I installed Sphinx and Thinking Sphinx on ruby-on-rails 2.3.2 and on Windows 7 pc. First of all, if I run rake ts:start, it won't start at all. It keep saying "Starting..." and it never starts. Even though, the simple search(with no filtering nor conditions) works fine. When I try to add a filter, it won't return any record. My mo...

Accessing Instance Variable from Controller In View

Hi, I am very new to Rails so this will probably seem basic to most of you. I am having trouble getting instance variables from one of my controller methods to show in my view. I am trying to get the first 10 entries of a MySQL table called Odds to show up in a table on my index view. Here is my Model: class Odds < ActiveRecord::B...

Does Model-View-Controller Play Nicely with Artificial Intelligence and Behavior Trees?

I come from an MVC background (Flex and Rails) and love the ideas of code separation, reusability, encapsulation, etc. It makes it easy to build things quickly and reuse components in other projects. However, it has been very difficult to stick with the MVC principles when trying to build complex, state-driven, asynchronous, animated a...

declarative_authorization is_in operator

I have what seems to me to be a simple declarative_authorization rule, but I'm sure it's just my newness that is causing me to have problems getting it to work. I have a user and a group. A group has a many-to-one relationship with a user. A particular class (:asset) can have a user & group associated with it. I want to determine au...

Rails syntax for comments in templates: is this bug understood?

Using rails 2.3.2 I have a partial _foo.rhtml that begins with a comment as follows: <% # here is a comment %> <li><%= foo %></li> When I render the partial from a view in the traditional way, e.g. <% some_numbers = [1, 2, 3, 4, 5] %> <ul> <%= render :partial => "foo", :collection => some_numbers %> </ul> I found that the <li> and ...

How do I pass 2 arguments using a simple form?

I have a very simple cart which displays the item quantity in a text_field, and the item name. I can fetch the proper data, I can't pass both of my arguments into my method (inventory ID and quantity). I'm receiving an argument error in my cart_update method of the inventories controller. add_to_cart.html.erb <% for item in @cart.items...

How to create a rails habtm that deletes/destroys without error?

I created a simple example as a sanity check and still can not seem to destroy an item on either side of a has_and_belongs_to_many relationship in rails. Whenever I try to delete an object from either table, I get the dreaded NameError / "uninitialized constant" error message. To demonstrate, I created a sample rails app with a Boy c...

Calling a Method from Within a Ruby Class? (or is this rails magic)

I'm new to Ruby and working through some tutorials/screencasts. I've reached the section where they're discusisng the before_filter callback, and it's using some syntax that's a little weird for me. I don't know if it's a feature of ruby, of if it's some rails magic, and was hoping someone here could set me straight or point me in the ...

Mahout Plugin for ruby on rails.

I want to use Apache Mahout in my project on Ruby on Rails for implementing recommendations and collaborative filtering. In Particular my requirements are: suggesting related tags. suggesting related articles. based on user's preferences prompt him for review of articles. based on geographical location, and other meta information of a ...

Specifying the foreign key in a has_many :through relationship

I have the following three models: User, Project, and Assignment. A User has_many Projects through an assignment. However, Assignment actually has two foreign keys that relate to a User: user_id (representing the user who was assigned the project) and completer_id (representing the user who completed the project). Often, user_id and co...

MissingSourceFile when I run "cucumber features"

I had cucumber 0.6.1 working quite fine... but I ran the gem update cucumber command, and things went smoothly. Then when I decided to run the cucumber features command, I received this error: Using the default profile... no such file to load -- cucumber/webrat/element_locator (MissingSourceFile) /usr/local/lib/ruby/site_ruby/1.8/rubyg...

error :Only get requests are allowed.

i get this exception ActionController::MethodNotAllowed: Only get requests are allowed. please can any one give solution for this ...

ActiveSupport::TestCase vs Test::Unit::TestCase when unit testing rails

I recently noticed my test database is not being cleaned up after my tests run if my tests subclass Test::Unit::TestCase. If my tests subclass ActiveSupport::TestCase, everything is cleaned up properly. Can anyone explain why, and/or provide an explanation of using one versus the other? I am using shoulda and factory_girl. Thanks. ...