Yesterday I updated our project from Rails 2.2.2 to Rails 2.3.4 and there seem to be major problems with MySQL: a lot of slow queries (up to 100-200 seconds), very high DB latency, lock timeout errors. I had to rollback to the previous version and now trying to investigate this strange behavior. Maybe someone experienced similar issues?
...
My Ruby on Rails blog application is getting a lot of comment spam for a particular blog post even though comments are closed and the comment form is no longer there. The comments are filtered by Akismet so they're not visible, but I'm not sure how my app should best respond to these requests.
I thought about simply redirecting to the p...
Implementing authentication with Authlogic, and role-based acl with Acl9, does a method exist, that will return what the role requirements are to access a given controller action?
...
Hi, I'm new to ruby on rails. So i think i have association problems.
Given the three model classes with their associations:
# user.rb
class User < ActiveRecord::Base
has_many :product_groups
has_many :products, :through=>:product_groups
end
# product_group.rb
class ProductGroup < ActiveRecord::Base
has_many :products
belongs_...
What would be the best way to implement integration test for chat application?
The problem is that I don't know how to implement two user behavior without stubbing and mocking everything.
How would you implement these steps?
Given I have two users "joe" and "bob" logged in
When "joe" send "Hello!" message to "bob"
Then "bob" should ...
I work on Ubuntu developing a Rails app for my church. We use a hosted VPS also on Ubuntu. I use Capistrano to deploy periodic updates. Inevitably, however, an app that works on my local box, always has a handful of problems after deploying to the host, most likely because the environments differ.
What are some practices/techniques t...
I am deploying a rails app to heroku which uses PostgreSQL as its back-end. In my database migration I normally set the ID field for things likes reports etc to at least 1000, most clients don't seem to like starting at 1.
Normally I use mysql and I simply add an sql specific after my table creation:
def self.up
create_table :repor...
I'm looking for the best way to build clean way to build role/authorisaton-based finders?
In my model schema, a user can have one of several (admin-defined) roles, such as Administrator, Regional Manager, Sales Assistant:
Example Given a User with a Regional Manager role and joined to a Region A, I would like to be able to query what ...
Suppose I am doing matchmaking of users and games.
I have models containing users and games.
class Game < ActiveRecord::Base
has_and_belongs_to_many :users
class User < ActiveRecord::Base
has_and_belongs_to_many :games
Games can have many users, users can be playing many games. Because of HASBM I have a table called games_use...
This is a separate question, but it is related to an earlier question: Three Column Join in Rails with Active Scaffold. To sum up: Rails automatically looks for a two column join table, but it doesn't do the same for a three column join table. I've tried the suggestions in the previous question, but it comes down to this:
If you have ...
Say I have these models
class Project < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :project
belongs_to :user
end
class User < ActiveRecord::Base
has_many :comments
end
So that I can do
p = Project.find(1, :include => :comments)
p.comments.collect(&:user).collect(&:name) #...
In one of my model objects I have an array of objects.
In the view I created a simple form to add additional objects to the array via a selection box.
In the controller I use the append method to add user selected objects to the array:
def add_adjacents
@site = Site.find(params[:id])
if request.post?
@site.adjacents << Site...
Hello stackies. The following PiP search was built for a project that lets users find their NYC governmental districts by address or lat/lng (http://staging.placeanddisplaced.org). It works, but its kinda slow, especially when searching through districts that have complex polygons. Can anyone give me some pointers on optimizing this code...
Any tools in Ruby or Rails that would allow me to extract from database all the table schema and generate Ruby equivalent "DLL" statements?
Something that would allow me to port schema from say Microsoft SQL Server to Postgres, or MySQL to Sqlite.
...
I can't find how to have generated files contain a header (with copyright info, etc.) in Rails 2.3.
I'd like all files generated automatically by the Rails Generator to have this header at the beginning of the file. How to do it?
...
I want to cycle through each page of a paginated model's index. I'm using jquery to cycle through the pages. I find the link_to expression is calling the create action when called by jquery. The link_to expressions calls the index action under any other circumstances.
For instance:
<div id="links">
<% 1.upto(@total_pages) do |numb...
This was working just the other day, but I just updated my code to the review server which runs Passenger 2.2.4 and my 2.3.4 rails app now can't boot on that box.
Passenger reports:
Passenger encountered the following error:
The application spawner server exited unexpectedly: Unexpected end-of-file detected.
Exception class:
Phus...
Hey,
How can I pass a boolean value in a form to a controller without the user being able to see or edit it? I'm assuming hidden_field is used for this, but how can I then assign a value to the variable?
Thanks for the help
-Pat
...
I have the following code in a partial view file: "_status.html.erb"
<%=
if session[:user].nil?
"welcome new user"
link_to( 'Sign in', login_path)
else
render ( :text => "user name:")
h(session[:user].name)
end
%>
But I only see the values of:
session[:user].name
(not the text "use...
I have a setup where I am using amcharts that is feed data via appendData from an AJAX call. The call goes to a URL which simply renders the Time.now as the X and 8 lines using the function 2cos(x/2)+2ln (ln is the line number). AJAX request is made every 1 second.
The backend is always correct and always returns a single point, unles...