similar to: How do you clean up this cryptic code?

Displaying 20 results from an estimated 1000 matches similar to: "How do you clean up this cryptic code?"

2006 Mar 14
3
Help doing find - look for nonempty habtm
I''ve got a Cuisine and a Restaurant model, with a habtm. One thing I want to do is find all the cuisines that have at least one restaurant associated with them. Right now I''m using the following SQL query: SELECT DISTINCT(cuisines.*) FROM cuisines, restaurants, cuisines_restaurants WHERE cuisines.id = cuisines_restaurants.cuisine_id AND restaurants.id =
2005 Mar 09
10
Confused about extending the login generator ''user''
I''ve been using the login generator ''out of the box'' for simple authentication, and its been working fine. Now I want to extend it by simply adding ''type_id'' field which links to my ''user_types'' table, but I''m hitting: #<ActionController::SessionRestoreError: Session contained objects where the class definition
2013 Jun 18
1
How to Pass Jquery selected dropdown values and radio button values to controller
Hi, I have an advance search page and its code is as follows - I have written my code like this <div class="container"> <%= form_tag search_index_path, method: :get do %> <%= radio_button_tag ''user_type'', ''customer'' %><p>Customer</p> <%= radio_button_tag ''user_type'',
2006 Jul 31
9
Multiple Pagination
I have the following: def index begin @restaurant_pages, @restaurants = paginate :restaurants, :order => (params[ :sort ] || "name"), :per_page => 2 @cuisines = Cuisine.find_all rescue redirect_to :action => :index end end # sort by cuisine def
2006 Jul 09
1
Quick Question
I have this method in a controller def sort_by_cuisine #@restaurants = Restaurant.find(:all, :conditions => ["cuisine_id = :id", params], :order => params[:sort]) @cuisines = Cuisine.find_all end And I want to put the bulk of it in the model, but still call it from the controller. How can I do this? I''m fairly new to Ruby on Rails and I''ve tried
2008 Apr 09
3
form_tag and form_for cause #protect_from_forgery errors
Hey All, I''m trying to do a simple form_for (and I also get it with form_tag) and I''m getting the following error: ActionView::TemplateError (No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).) on line #2 of users/new.fbml.erb: 1: <h1>Welcome To Courses, Let''s Get
2006 Apr 19
2
Beginner problem with foreign keys
Hi, I''ve been trying to get this to work all night. I''ve made some progress by reading other posts, but I''m stuck now and can''t figure out what I am doing wrong. I have two tables: application_users and user_types. In my application_users table I have a field named "user_type_id". At first, I thought if I set up the foreign key with the correct
2006 May 04
9
Help: wrong number of arguments (0 for 1)
Is it my environment? Is something wrong, cause I thought this should just work? I have a simple table and I created a model and a controller: ruby script/generate controller Restaurant ruby script/generate model Restaurant I edited the controller to this: class RestaurantController < ApplicationController scaffold :Restaurant end I run it and: http://0.0.0.0:3000/Restaurant works fine,
2009 Oct 15
10
AJAX - how to have multiple select form sets implemented?
hi, there :) Consider a blogging application whereby a user is trying to add a new blog. He/she has to select a category. Upon selecting a category from a drop down box, a new sub categories drop down box will be created (hence an AJAX call). Got this implemented and it''s ok. Now, let''s assume that a given blog can have multiple categories (and subcategories). For example, a
2008 Apr 03
1
Anyone experienced RSpec/Autotest forgetting models?
Hi Saving a controller spec frequently gives me this error: 52) LoadError in ''UsersController GET /users with basic request params should find all the user types'' Expected /home/amoran/Documents/becta/apps/Backend/app/models/user_type.rb to define UserType ./spec/controllers/users_controller_spec.rb:299: script/spec:4: I have to Ctrl-C autotest before it will load again.
2006 Aug 22
0
Re: Problem with find condition and habtm relationship.
OK. This may help, but it will also make your head hurt. The basic problem that you''re running into is that you want a "for all" operator and sql doesn''t have one. Instead, you have to think of the query in terms of the logically equivalent "not exists not". Effectively, a proposition is true for all x if you can''t find a counter-example in
2008 Mar 28
2
Wrong story step running
Hi I have three steps like this: Given ''a user called "$name" of type $user_type and status $user_state in organisation "$organisation_name"'' do |name, user_type, user_state, organisation_name| $runs ||= 1 puts "MOO #{$runs}" $runs += 1 # ... end Given ''a user called "$name" with username
2005 Mar 10
0
RE: Confused about extending the login generator ''user'' [fixed]
>> that should be "belongs_to :user_type" Bingo! -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Jarkko Laine Sent: Wednesday, 9 March 2005 6:59 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] Confused about
2005 Jul 09
2
Modifying astcc
Hi: Astcc is working fine, except for one thing. It doesn't give the called party enough time to answer the phone. If nobody picks up in two rings, astcc reports back no answer and hangs-up. The only instant NOANSWER "value" was mentioned in astcc.agi script is: elsif ($res eq "NOANSWER") { $res = &mystreamfile("astcc-noanswer");
2007 Aug 20
1
Application for Home Delivery Restaurants
Hello All We have developed an application for Home Delivery Restaurants using Asterisk, Java (JSP/ JSF) and MySQL. Here is listing of its features. If someone is interested then we can provide him more details. - POP up window with caller data containing his/her name, address and transactions history. - In case of new customer, Pop up window with blank form to add customer data and
2012 Dec 16
3
Running code in another controller action
I am doing a partial render in the view from one controller. Here is the code -> <%= render :template => ''restaurants/new'' %>. I want the other controller new action code to do it. Is there a way to call an action in another controller ? I don''t want to duplicate the same code in two controllers. -- You received this message because you are
2006 May 03
0
Newbie Help
Is it my environment? Is something wrong, cause I thought this should just work? I have a simple table and I created a model and a controller: ruby script/generate controller Restaurant ruby script/generate model Restaurant I edited the controller to this: class RestaurantController < ApplicationController scaffold :Restaurant end I run it and: http://0.0.0.0:3000/Restaurant works
2006 May 01
0
PostGIS and MySql Spatial Extensions in Rails
Hello, This post is to announce a new release of the Spatial Adapter for Rails, which is a plugin that adds support for columns of geometric types (point, linestring, polygon,etc...) to ActiveRecord. Currently the only supported databases are MySql and PostGIS. With this release, geometric columns should behave like columns of any other basic types in all areas: migration, data access, dumping
2009 May 14
3
Mysql query is not working
Please, Can anyone help me to execute this query? SELECT * FROM table WHERE customer_id IN (SELECT IF(1 <> 2,''SELECT customer_id FROM customers'',''SELECT customer_id FROM company'')) Regards... -- Posted via http://www.ruby-forum.com/.
2006 May 14
4
searching on foreing keys
Hey all, I''m using a simple search function. It''s working great except for foreign keys. I have one table pets (id,name,owner_id) and another table people(id,name) owner_id being a foreign key of pet pointing to people name. here it is on the pet controller: @paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id like