If I call ActiveRecord#create and ActiveRecord#destroy method several hundreds times(more than 200), Status: 500 Internal Server Error, ActionController::Session::CookieStore::CookieOverflow occured.
How can I fix this problem?
...
I have boxes and balls. Balls are in boxes. Ball can be either red and green.
class Box < ActiveRecord::Base
has_many :balls
end
class Ball < ActiveRecord::Base
belongs_to :box
scope :green, where(:color => "green")
end
I want to set has_many only with green balls. I know that finder_sql method exists, but i don't know how to s...
I'm using Rails 2.3.8 + redis + resque + redis-namespace
This is part of my environment.rb
config.gem 'jrails'
config.gem 'haml'
config.gem 'redis'
config.gem 'redis-namespace'
config.gem 'resque
This is my gem list
redis (2.0.3)
redis-namespace (0.7.0)
resque (1.9.7)
When I start my server by 'script/server', it show su...
I'm using rails 2.3.8 and redis.
In my controllers, each time I want to access redis, I will create a new Redis object, like:
class AbcController < ApplicationController
def index
redis => Redis.new
redis.xxx
end
def list
redis => Redis.new
redis.xxx
end
end
I feel this is very bad, and I have some questi...
What am I doing wrong here??
features = WidgetFeature.all(:conditions => {:widget_id=>params[:id], :children_features=>nil, :filterable => true" })
I want to find all those features where widget_id = params[:id] AND children_features IS NIL AND filterable IS TRUE
...
My back end is my Rails server which sends JSON data to my front end. In the front end, I am using javascript and jQuery which processes my JSON data and displays some of it.
Now, the user can inputs a number depending on the data displayed to it.
So, on the basis of input from user, certain changes are made to JSON data received earlier...
I have use activerecord to access data from db. It works fine in localhost but when I tried it on another server, I get the following errors:
ActiveRecord::StatementInvalid (Mysql::Error: PROCEDURE db_name.proc_spName can't return a result set in the given context: CALL proc_spName(............)):
/vendor/rails/activerecord/lib/acti...
How to find the closing of an application window without ' log out' the session .This is to prevent the user from directly going to the previous session. In such cases, the user session should end and direct the user to the login page.
...
Hi!
I'm struggling a bit to find the right place for a helper method. The method basicly 'inspects' a User-model object and should return some information about the 'progress' of the user, eg. "You need to add pictures", "Fill out your address" or "Add your e-mail-adress". None of the conditions I'm checking for are required, it's just ...
Here is the code generated by rails:
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
flash[:notice] = 'User was successfully updated.'
format.html { redirect_to(@user) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
...
Assume that I have a global variable user in application....like this:
# GET /users.xml
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
Is that mean every request, a new @user is created? If every request , an object is cre...
Controller:
class GalleriesController < ApplicationController
def index
@galleries = Gallery.all
end
end
View:
<% for gallery in @galleries %>
<%= image_tag(gallery.image.url(:medium)) %>
<% end %>
I have 2 models, Photo which belongs to Gallery,which has many Photos.
I want to display an image (preferably random rather t...
OK, assume that I have a post table, and a category table. This is the model look like:
class User < ActiveRecord::Base
acts_as_authentic
has_many :posts
end
and, that is the post models:
class Post < ActiveRecord::Base
belongs_to :user
end
And this is the new.html.erb from post:
<% form_for(@post) do |f| %>
<%...
When I deployed my latest application, my all.js file was never created. It's because of this that my entire website receives a 500 error.
I can't find too much information on the all.js file out there.
Does anyone know how this file is generated, and what may have caused this error?
Thanks!
...
Hey all,
i need a little help with a AR query. This is how my models look like:
class User < AR:B
has_many :publications
end
class Publication < AR:B
belongs_to :user
belongs_to :category
end
class Category < AR:B
has_many :publications
end
Now let's say I want to iterate over all existing categories and either display the ...
<%= submit_tag "Delete" , :confirm => 'Are you sure you want to delete the selected?' %>
doesn't work.
how do I do this?
...
So.. here is my link_to
<%= link_to "Archive", :action => 'archive' %>
and my output in the console
Parameters: {"action"=>"archive", "controller"=>"achievables"}
why is the action not "archive" ?
the method is defined in the controller... spelled correctly and everything.
EDIT:
from routes.rb
map.archives 'achievable/archive',...
I noticed a problem with indexing my rails app when submitting it to Google webmaster tools and testing with curl.
My root is currently set like so:
map.root :controller => "posts"
which will explain when i run:
$ curl http://0.0.0.0:3000
it only returns the posts controller and not the homepage in its entirety:
<div class="post"...
Why does this error happen? I didn't do anything to that file?
my links that call javascript are within a from... that shouldn't be a problem though.. right?
The offending code block:
getElements: function(form) {
return $A($(form).getElementsByTagName('*')).inject([],
function(elements, child) {
if (Form.E...
The situation will like this .... .... a user have many posts. But if I loop back all the posts, it will become very slow. So, I may look back the first ten (1-10). When the user click "next", it will get the (11-20). So, my question is, how can I implement it?? thank you.
<%=h @user.posts.inspect %> <!--It can show all the posts, but...