[Rails] Re: sub accounts
On Mar 21, 10:46 pm, Loganathan Ganesan wrote: > mlittle wrote: > > On Mar 21, 10:33 pm, Loganathan Ganesan wrote: > >> I suggest the following database model: > >> UserID > > >> In the models > > >> Users => has_many :sub_users > >> sub_users => belongs_to :User > > >> so, you should delete first sub_users records, then Users table records. > >> -- > >> Posted viahttp://www.ruby-forum.com/. > > > Seems too easy :). How would I handle the confirmation email and > > related issues? Thanks a bunch for the response. I do appreciate it!! > mo > I don't really understand what are you trying to mean about confirmation > email and related issues ? > If u don't mind can u explain me in detail? > > Thanks > -- > Posted viahttp://www.ruby-forum.com/. I'm going to look at the code more but I was talking about creating the user just like I would with restful_authentication. I see what you are saying but I am still not clear how the new user in sub_user would be able to login, logout, and basically do the same as the users in Users. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Re: Issues RUNNING mysql gem
On Sun, Mar 21, 2010 at 9:43 PM, Mike Montagne wrote: > These are regular concerns for anyone with a background in RDBMS, just > now getting their feet wet in RoR. Let it go, at least for a short vacation :-) Do a quick search on "premature optimization". Consider that the whole point of an agile framework like Rails is to facilitate getting features to customers, quickly. Having to optimize your app to handle too-many-page-views is a good problem, but you can deal with it closer to the actual event. -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: sub accounts
mlittle wrote: > On Mar 21, 10:33�pm, Loganathan Ganesan wrote: >> I suggest the following database model: >> UserID >> >> In the models >> >> Users � => has_many :sub_users >> sub_users => belongs_to :User >> >> so, you should delete first sub_users records, then Users table records. >> -- >> Posted viahttp://www.ruby-forum.com/. > > Seems too easy :). How would I handle the confirmation email and > related issues? Thanks a bunch for the response. I do appreciate it!! I don't really understand what are you trying to mean about confirmation email and related issues ? If u don't mind can u explain me in detail? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: sub accounts
On Mar 21, 10:33 pm, Loganathan Ganesan wrote: > mlittle wrote: > > I am using restful authentication and was wondering if anyone has had > > any experience with sub accounts. Basically, I want a user to have the > > ability to add another user(s) to his/her account. So if user A > > creates an account I would like them to have the ability to add new > > users to their account - B, C, etc. B and C would "belong" to A and if > > A's account is deleted so is B and C. Makes sense? Any information on > > how to achieve this would be greatly appreciated. > > This can be done by using the relationships among the tables. > I suggest the following database model: > > Users ( Table ) > - > > ID > Name > > sub_users ( Table) > > ID references Users(ID) > UserID > > In the models > > Users => has_many :sub_users > sub_users => belongs_to :User > > so, you should delete first sub_users records, then Users table records. > -- > Posted viahttp://www.ruby-forum.com/. Seems too easy :). How would I handle the confirmation email and related issues? Thanks a bunch for the response. I do appreciate it!! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: sub accounts
mlittle wrote: > I am using restful authentication and was wondering if anyone has had > any experience with sub accounts. Basically, I want a user to have the > ability to add another user(s) to his/her account. So if user A > creates an account I would like them to have the ability to add new > users to their account - B, C, etc. B and C would "belong" to A and if > A's account is deleted so is B and C. Makes sense? Any information on > how to achieve this would be greatly appreciated. This can be done by using the relationships among the tables. I suggest the following database model: Users ( Table ) - ID Name sub_users ( Table) ID references Users(ID) UserID In the models Users => has_many :sub_users sub_users => belongs_to :User so, you should delete first sub_users records, then Users table records. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: "Missing Template" when manually creating views
tuti plain wrote: > Hi everyone, > > I am trying to set up a controller and a view manually, without the > aid of scaffolding (though I am using a scaffolded model as reference). > > I have set up my controller like this: > > class RecetasController < ApplicationController > def index > respond_to do |format| > format.html #index.html.erb > end > end > end > > I have created a single file named index.html.erb inside > app/views/receta. So far in only has a few HTML lines. When I access > http://localhost:3000/recetas, I get this message on my browser: > > "Missing template recetas/index.erb in view path app/views" > > What gives? Scaffolded models generate .html.erb files and they work > right! So I go ahead and change my view to be named index.erb. I still > get the same error message! What am I missing? Could you please give the log printed in the webrick ? Actually I faced this error during the time of placing wrong code inside environment.rb file. Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Rails 3: Update responding with empty json
On Sun, Mar 21, 2010 at 6:27 PM, Fabio Kreusch wrote: > Hi Conrad, > I have tried Rails console, and while trying to convert to json the > results were the expected. > > This is the Jquery code used on my ajax form: > > $('#category_form').submit(function() { >var form = $(this); >$.ajax({ > url: form.attr('action'), > type: 'POST', > data: form.serialize(), > success: function(data, status, req) { >reloadCategories(); > }, > error: function(req, status, error) { >setFormErrors(form, req); > } >}); >return false; > }); > > This function is used with both create and update forms, but on create > everything goes ok and it falls on the success function, while during > update, the JSON result comes blank, Jquery gets an error while trying > to parse the empty Json object and it falls on the error function. > .. > Can you post the view template of the form? -Conrad > > On Mar 21, 10:16 pm, Conrad Taylor wrote: > > On Sun, Mar 21, 2010 at 4:41 PM, Fabio Kreusch > wrote: > > > Thanks Conrad, I have removed the save call from the code, but it > > > continues to return an empty JSON on success case. > > > Any more clues? > > > > Fabio, what happens in the Rails 3 console? For example, you can do the > > following in the Rails console: > > > > a) get a user > > b) retrieve a category from the user's list of categories > > c) convert the result in (b) into json > > > > Next, what does the jQuery code look like? > > > > -Conrad > > > > > > > > > On Mar 21, 3:37 pm, Conrad Taylor wrote: > > > > On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch > > > wrote: > > > > > Hi all! > > > > > > > I'm playing with Rails 3, and on one of my controllers I have the > > > > > following update method defined: > > > > > > > def update > > > > >@category = @user.categories.find(params[:id]) > > > > >@category.update_attributes(params[:ecategory]) > > > > >@category.save > > > > >respond_with @category > > > > > end > > > > > Fabio, you should not be calling save within the update > > > > action because 'update_attributes' calls save implicitly. > > > > Thus, you should do something like the following: > > > > > > class CategoriesController < ApplicationController::Base > > > > > > respond_to :html, :json > > > > > > def update > > > > > >@category = @user.categories.find( params[:id] ) > > > > > > if @category.update_attributes( params[:category] ) > > > > > > flash[:notice] = 'Category was successfully created.' > > > > > > end > > > > > >respond_with( @category ) > > > > > > end > > > > > > end > > > > > > Good luck, > > > > > > -Conrad > > > > > > I'm using Jquery to interact with the controllers, and when I do an > > > > > > > ajax PUT, the update action is correctly executed (the fields are > > > > > updated), but the action returns an empty JSON object, which causes > > > > > the Jquery ajax function to fall into an error. > > > > > > > I'm I doing something wrong? > > > > > > > Thank you all, > > > > > Fabio. > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "Ruby on Rails: Talk" group. > > > > > To post to this group, send email to > rubyonrails-talk@googlegroups.com > > > . > > > > > To unsubscribe from this group, send email to > > > > > rubyonrails-talk+unsubscr...@googlegroups.com e...@googlegroups.com> > > e...@googlegroups.com> > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscr...@googlegroups.com e...@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: Issues RUNNING mysql gem
Hassan Schroeder wrote: > On Sun, Mar 21, 2010 at 7:24 PM, Mike Montagne > wrote: > >> What's the basic procedure for local development and deployment of the >> tables? Do you suffer the database-agnostic field definitions of the >> local development environment (db:create and db:migrate); or, wanting to >> test with real field definitions, to you go ahead and refine your table >> declarations locally, as you would in what you deploy to the server? > > I'm not sure what you mean by "real field definitions" -- can you go > into a little more detail? What is it you think you can't do within the > scope of migrations? > > And "deploy to the server" can cover a lot of different scenarios, so > you might want to describe what you mean by that, too. > > -- > Hassan Schroeder hassan.schroe...@gmail.com > twitter: @hassan 1. "Real field definitions": There's a big difference between scaffolding: script/generate scaffold tablename amendment_id:integer first_name:string middle_name:string last_name:string anonymous_signature:boolean email_address:string email_bounces:integer referrer_email:string referrer_id:integer address1:string address2:string city:string c_code:string state_province_or_territory:string zip_or_postal_code:string comment:string And the usual SQL route to creating a table: CREATE TABLE tablename (id integer NOT NULL AUTO_INCREMENT PRIMARY KEY, ip integer, amendment_id integer, first_name varchar(25), middle_name varchar(25), last_name varchar(30), anonymous_signature tinyint, email_address varchar(100), email_bounces tinyint, referrer_email varchar(100), address1 varchar(100), address2 varchar(100), city varchar(25), c_code varchar(2), state_province_or_territory varchar(2), zip_or_postal_code varchar(10), comment varchar(125), created_at datetime, updated_at datetime) ENGINE = INNODB; In the former, you're not even passing the information to the environment to build the tables you want. Of course then, it's critical to convey your intended design to deployment. A varchar(25) (intended field designation) requires 1/10th the disk resources that a string field (which translates to varchar(255)). Migrating the database agnostic definitions of scaffolding then is not producing the intended schema result. 2. Thus the concern about migrating the scaffolding schema's limited means of defining an intended schema with automated deployment processes, which still lack even the data from which your intended schema could be deduced. You've never provided it. So, what I'm asking is, how do you usually handle these issues in RoR? Do you just tolerate the consequences of scaffolding; or do you test and develop on your intended schema; and, if you modify the schema to your intentions with additional tools, is that preserved or destroyed by further migrations? My inclination is to want to revise/refine the resultant schema to my intended table design. I'm also concerned about how RoR deployment might inadvertently affect my schema on a destination server. How do you ensure migrations to a production table don't affect the intended schema of installed tables? These are regular concerns for anyone with a background in RDBMS, just now getting their feet wet in RoR. Thanks, m -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: how to specify relationship between these models
Hi Lots of thanks for all your reply. What I am finally doing is following. (Is it you people suggested?). I have still problem in creating the view for adding a staff. Please correct me if what I am doing is wrong way. users - name email phone etc staffs -- city state user_id Now in staff controller def new @user = User.new end staff/new.html.erb <% form_for @user,:url => staff_index_url, do |u| %> <%= u.text_field :first_name,:maxlength => 50 %> <% u.fields_for :staff do |s| %> <%= s.text_field :address_street1,:maxlength => 50 %> <%end%> <%= submit_tag "ok"%> <%end%> Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] "Missing Template" when manually creating views
Hi everyone, I am trying to set up a controller and a view manually, without the aid of scaffolding (though I am using a scaffolded model as reference). I have set up my controller like this: class RecetasController < ApplicationController def index respond_to do |format| format.html #index.html.erb end end end I have created a single file named index.html.erb inside app/views/receta. So far in only has a few HTML lines. When I access http://localhost:3000/recetas, I get this message on my browser: "Missing template recetas/index.erb in view path app/views" What gives? Scaffolded models generate .html.erb files and they work right! So I go ahead and change my view to be named index.erb. I still get the same error message! What am I missing? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Routing error in Rails 3
Turns out this was caused because my controller was singular (ProspectController) instead of plural (ProspectsController). On Mar 20, 12:42 pm, rjunee wrote: > I use: > > <% form_for @prospect do |f| %> > > which generates: > > method="post"> > > Cheers, > Ryan > > On Mar 20, 5:31 am, Conrad Taylor wrote: > > > > > On Sat, Mar 20, 2010 at 1:52 AM, rjunee wrote: > > > I'm hoping someone can advise me on how to debug this routing error. > > > > My routes.rb includes: > > > resources :prospects, :only => ["create"] > > > > rake routes shows: > > > prospects POST /prospects(.:format) > > > {:controller=>"prospects", :action=>"create"} > > > > However when I try to post a form I get: > > > > Started POST "/prospects" for 127.0.0.1 at 2010-03-20 01:44:29 > > > > ActionController::RoutingError (No route matches "/prospects"): > > > > Rendered /Users/ryan/.rvm/gems/ruby-1.9.1-p378/gems/ > > > actionpack-3.0.0.beta/lib/action_dispatch/middleware/templates/rescues/ > > > routing_error.erb within /Users/ryan/.rvm/gems/ruby-1.9.1-p378/gems/ > > > actionpack-3.0.0.beta/lib/action_dispatch/middleware/templates/rescues/ > > > layout.erb (0.9ms) > > > > Any ideas? > > > Hi, how are you trying to post the form? > > > -Conrad > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-t...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscr...@googlegroups.com > > e...@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Issues RUNNING mysql gem
On Sun, Mar 21, 2010 at 7:24 PM, Mike Montagne wrote: > What's the basic procedure for local development and deployment of the > tables? Do you suffer the database-agnostic field definitions of the > local development environment (db:create and db:migrate); or, wanting to > test with real field definitions, to you go ahead and refine your table > declarations locally, as you would in what you deploy to the server? I'm not sure what you mean by "real field definitions" -- can you go into a little more detail? What is it you think you can't do within the scope of migrations? And "deploy to the server" can cover a lot of different scenarios, so you might want to describe what you mean by that, too. -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] sub accounts
I am using restful authentication and was wondering if anyone has had any experience with sub accounts. Basically, I want a user to have the ability to add another user(s) to his/her account. So if user A creates an account I would like them to have the ability to add new users to their account - B, C, etc. B and C would "belong" to A and if A's account is deleted so is B and C. Makes sense? Any information on how to achieve this would be greatly appreciated. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Issues RUNNING mysql gem
Hassan Schroeder wrote: > > Are you reading any of the responses? > > -- > Hassan Schroeder hassan.schroe...@gmail.com > twitter: @hassan :-) Sorry, Hassan. I didn't see your response yet. But until I left to here, I read the whole thread. Thanks for the answer, and let me ask you one thing then: What's the basic procedure for local development and deployment of the tables? Do you suffer the database-agnostic field definitions of the local development environment (db:create and db:migrate); or, wanting to test with real field definitions, to you go ahead and refine your table declarations locally, as you would in what you deploy to the server? Thanks, mike -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Issues RUNNING mysql gem
Sorry for this. It's my first go-around with RoR/MySQL. Got it: rake db:create RAILS_ENV='development' Then: rake db:migrate --trace -- Still, if anybody has any general pointers about how to go about developing MySQL locally... much appreciated. Regards, mike -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Using ActionMailer on a controller method
The value of @ticket is represted as an array of all the attributes of the ticket itself. I just realized that. I had to change my link_to arguments just slightly... On Mar 21, 3:38 pm, Michael Pavling wrote: > On 21 March 2010 21:29, command0 wrote: > > > I have: > > > map.resources :tickets, :has_many => [:notes, :comments] > > > In routes.rb. > >> > 5: You can view your ticket at <%= link_to @ticket %>. > > Okay, > So when we get to line 5 of app/views/ticket_mailer/newticket.erb, > you're passing the @ticket variable to the link_to helper... so what's > the value of @ticket at this stage? Is it actually a "Ticket" object, > or is it Nil? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Issues RUNNING mysql gem
On Sun, Mar 21, 2010 at 6:25 PM, Mike Montagne wrote: > Does anybody have any idea what I still have fudged up here? Why isn't > the database being created? Are we supposed to manually create our > database schema when working with the MySQL gem? You have to create your databases regardless of what DB you're using -- as I just pointed out in your previous thread. Are you reading any of the responses? -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: Link as a link AND as a function
Gotcha! Perfect. Thank you Jeffrey. I got it to work with the following. In my view: <%= link_to_function truncate(link.name, 60), "clickThru('#{link.link}','#{link[:id]}', 'votes')", :title => link.name, :href => link.link %> In my application.js function clickThru(url, id, verb) { new Ajax.Request('/links/'+id+'/'+verb, {asynchronous:true, evalScripts:true, method:'post'}); window.open(url); } Thank you so much! This was awesome and your advise came at the end of maybe 5 hours of internet searching. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Rails 3: Update responding with empty json
Hi Conrad, I have tried Rails console, and while trying to convert to json the results were the expected. This is the Jquery code used on my ajax form: $('#category_form').submit(function() { var form = $(this); $.ajax({ url: form.attr('action'), type: 'POST', data: form.serialize(), success: function(data, status, req) { reloadCategories(); }, error: function(req, status, error) { setFormErrors(form, req); } }); return false; }); This function is used with both create and update forms, but on create everything goes ok and it falls on the success function, while during update, the JSON result comes blank, Jquery gets an error while trying to parse the empty Json object and it falls on the error function. .. On Mar 21, 10:16 pm, Conrad Taylor wrote: > On Sun, Mar 21, 2010 at 4:41 PM, Fabio Kreusch wrote: > > Thanks Conrad, I have removed the save call from the code, but it > > continues to return an empty JSON on success case. > > Any more clues? > > Fabio, what happens in the Rails 3 console? For example, you can do the > following in the Rails console: > > a) get a user > b) retrieve a category from the user's list of categories > c) convert the result in (b) into json > > Next, what does the jQuery code look like? > > -Conrad > > > > > On Mar 21, 3:37 pm, Conrad Taylor wrote: > > > On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch > > wrote: > > > > Hi all! > > > > > I'm playing with Rails 3, and on one of my controllers I have the > > > > following update method defined: > > > > > def update > > > > �...@category = @user.categories.find(params[:id]) > > > > �...@category.update_attributes(params[:ecategory]) > > > > �...@category.save > > > > respond_with @category > > > > end > > > Fabio, you should not be calling save within the update > > > action because 'update_attributes' calls save implicitly. > > > Thus, you should do something like the following: > > > > class CategoriesController < ApplicationController::Base > > > > respond_to :html, :json > > > > def update > > > > �...@category = @user.categories.find( params[:id] ) > > > > if @category.update_attributes( params[:category] ) > > > > flash[:notice] = 'Category was successfully created.' > > > > end > > > > respond_with( @category ) > > > > end > > > > end > > > > Good luck, > > > > -Conrad > > > > I'm using Jquery to interact with the controllers, and when I do an > > > > > ajax PUT, the update action is correctly executed (the fields are > > > > updated), but the action returns an empty JSON object, which causes > > > > the Jquery ajax function to fall into an error. > > > > > I'm I doing something wrong? > > > > > Thank you all, > > > > Fabio. > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Ruby on Rails: Talk" group. > > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > > . > > > > To unsubscribe from this group, send email to > > > > rubyonrails-talk+unsubscr...@googlegroups.com > > > e...@googlegroups.com> > e...@googlegroups.com> > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com > e...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Issues RUNNING mysql gem
Hi, all. With unbelievable difficulty, I have the mysql gem installed without warnings with the following components: OSX Leopard 10.6.2 ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] Rails 2.3.5 mysql (2.8.1) [gem version] MySQL Server 5.1.44 I even rebuilt my whole project a few minutes ago, thinking an unsuccessful previous install might have failed to generate my database. Yet when I run rake db:migrate, I get the following errors: iMacMike:pfmpe mikemontagne$ rake db:migrate --trace (in /Users/mikemontagne/rproj/pfmpe) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! Unknown database 'pfmpe_development' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:589:in `real_connect' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:589:in `connect' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:203:in `initialize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:75:in `new' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:75:in `mysql_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:435:in `initialize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in `new' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in `up' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:in `migrate' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling' /System/Library
Re: [Rails] Re: Rails 3: Update responding with empty json
On Sun, Mar 21, 2010 at 4:41 PM, Fabio Kreusch wrote: > Thanks Conrad, I have removed the save call from the code, but it > continues to return an empty JSON on success case. > Any more clues? > > Fabio, what happens in the Rails 3 console? For example, you can do the following in the Rails console: a) get a user b) retrieve a category from the user's list of categories c) convert the result in (b) into json Next, what does the jQuery code look like? -Conrad > On Mar 21, 3:37 pm, Conrad Taylor wrote: > > On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch > wrote: > > > Hi all! > > > > > I'm playing with Rails 3, and on one of my controllers I have the > > > following update method defined: > > > > > def update > > >@category = @user.categories.find(params[:id]) > > >@category.update_attributes(params[:ecategory]) > > >@category.save > > >respond_with @category > > > end > > > > Fabio, you should not be calling save within the update > > action because 'update_attributes' calls save implicitly. > > Thus, you should do something like the following: > > > > class CategoriesController < ApplicationController::Base > > > > respond_to :html, :json > > > > def update > > > >@category = @user.categories.find( params[:id] ) > > > > if @category.update_attributes( params[:category] ) > > > > flash[:notice] = 'Category was successfully created.' > > > > end > > > >respond_with( @category ) > > > > end > > > > end > > > > Good luck, > > > > -Conrad > > > > I'm using Jquery to interact with the controllers, and when I do an > > > > > > > > > ajax PUT, the update action is correctly executed (the fields are > > > updated), but the action returns an empty JSON object, which causes > > > the Jquery ajax function to fall into an error. > > > > > I'm I doing something wrong? > > > > > Thank you all, > > > Fabio. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscr...@googlegroups.com e...@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] mysql gem migrate "Unknown database '[db_development]" error
On Sun, Mar 21, 2010 at 5:45 PM, Mike Montagne wrote: > iMacMike:pfmpe mikemontagne$ rake db:migrate --trace > Unknown database 'pfmpe_development' > database.yml indicates that this is supposed to be the development > database. But no such file exists in my project directory. What file would you expect? This refers to a database, physical location dependent on your MySQL configuration. > Is this a MySQL server configuration issue? Does anybody understand why > this table is not being created? Perhaps you left out the step where you create it? At least I didn't see it in your post. You can create databases manually through the MySQL CLI console or a number of other tools, or you can run the appropriate rake task. `rake -T` will give you a list of the available tasks. But you *do* have to create it before running your migrations :-) HTH, -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Rails + Mysql
José Luis Romero wrote: > Done! Same results... > > uninitialized constant MysqlCompat::MysqlRes > > Thanks... Any other approach? Try setting ARCHflags. OSX Snow Leopard will return the same results you're getting if you don't set the ARCHflags. You'll have to look them up for your system, but the syntax is something like this: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config When you get the ARCHflags parameter right, that should resolve your uninitialized constant issue. If you then get the "No definition for [ResourceName]" ri and RDoc warnings/errors, first uninstall your gem again, and then you'll have to do something like this: sudo env ARCHFLAGS="-arch x86_64" gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config http://forums.mysql.com/read.php?116,359591,359591#msg-359591 That may or may not be enough to get the mysql gem working in your environment. I'm still tracing out problems. Regards, mike -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] mysql gem migrate "Unknown database '[db_development]" error
Nikhil Gupte wrote: > Jean, > > Best is to install macports, if you aren't already using it. > > To re-compile ruby, run: > > sudo port install ruby I was able to get mysql gem to install on OSX Leopard without warnings with the --no-rdoc and --no-ri switches; archflags likewise eliminated the uninitialized constant error: sudo gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config That hasn't made my installation functional however. I just rebuilt my entire project with rails myApp -d mysql; I then scaffolded 5 sets of tables (i.e. script/generate scaffold tablename c_code:string c_name:string tran_id:integer priority:integer); I next drag the project directory onto XCode Organizer; create the start server script (script/server); and start the gem server in terminal: gem server. Fine and dandy so far (seemingly). Then I run rake db:migrate to engender the following error: iMacMike:pfmpe mikemontagne$ rake db:migrate --trace (in /Users/mikemontagne/rproj/pfmpe) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! Unknown database 'pfmpe_development' -- database.yml indicates that this is supposed to be the development database. But no such file exists in my project directory. Is this a MySQL server configuration issue? Does anybody understand why this table is not being created? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Rails 3: Update responding with empty json
Thanks Conrad, I have removed the save call from the code, but it continues to return an empty JSON on success case. Any more clues? On Mar 21, 3:37 pm, Conrad Taylor wrote: > On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch wrote: > > Hi all! > > > I'm playing with Rails 3, and on one of my controllers I have the > > following update method defined: > > > def update > > �...@category = @user.categories.find(params[:id]) > > �...@category.update_attributes(params[:ecategory]) > > �...@category.save > > respond_with @category > > end > > Fabio, you should not be calling save within the update > action because 'update_attributes' calls save implicitly. > Thus, you should do something like the following: > > class CategoriesController < ApplicationController::Base > > respond_to :html, :json > > def update > > �...@category = @user.categories.find( params[:id] ) > > if @category.update_attributes( params[:category] ) > > flash[:notice] = 'Category was successfully created.' > > end > > respond_with( @category ) > > end > > end > > Good luck, > > -Conrad > > I'm using Jquery to interact with the controllers, and when I do an > > > > > ajax PUT, the update action is correctly executed (the fields are > > updated), but the action returns an empty JSON object, which causes > > the Jquery ajax function to fall into an error. > > > I'm I doing something wrong? > > > Thank you all, > > Fabio. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com > e...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: auto_complete plugin on rails 2.3.5
thanks. Guido On 20 Mar, 00:47, Fernando Perez wrote: > > Someone can help me? > > Just grab it from github and drop it in vendor/plugins, there is no > special install step to run. > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Using ActionMailer on a controller method
On 21 March 2010 21:29, command0 wrote: > I have: > > map.resources :tickets, :has_many => [:notes, :comments] > > In routes.rb. >> > 5: You can view your ticket at <%= link_to @ticket %>. Okay, So when we get to line 5 of app/views/ticket_mailer/newticket.erb, you're passing the @ticket variable to the link_to helper... so what's the value of @ticket at this stage? Is it actually a "Ticket" object, or is it Nil? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Using ActionMailer on a controller method
I have: map.resources :tickets, :has_many => [:notes, :comments] In routes.rb. On Mar 21, 3:20 pm, Michael Pavling wrote: > On 21 March 2010 21:01, command0 wrote: > > > 5: You can view your ticket at <%= link_to @ticket %>. > > Do you have "map_resources :tickets" in your routes.rb file? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Using ActionMailer on a controller method
On 21 March 2010 21:01, command0 wrote: > 5: You can view your ticket at <%= link_to @ticket %>. Do you have "map_resources :tickets" in your routes.rb file? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Using ActionMailer on a controller method
LOL yeah, I was so tired when I was working on this earlier this morning, I just totally overlooked that. When I change the assignment, I get the "Need controller and action!" error. In the View, here is the whole verbage it spits out: ActionController::RoutingError in Tickets#create Showing app/views/ticket_mailer/newticket.erb where line #5 raised: Need controller and action! Here are the new params: --- [4;35;1mSQL (0.1ms) [0m[0mSET NAMES 'utf8' [0m [4;36;1mSQL (0.1ms) [0m[0;1mSET SQL_AUTO_IS_NULL=0 [0m Processing TicketsController#create (for 127.0.0.1 at 2010-03-21 14:52:09) [POST] Parameters: {"ticket"=>{"platform_id"=>"", "title"=>"Testing the mailer", "app_version"=>"", "app_id"=>"", "category_id"=>"5", "user_id"=>"2", "os_version"=>"", "status_id"=>"1", "desc"=>"Let's see what happens.", "customer_id"=>"1", "notes_attributes"=>{"0"=>{"body"=>"Trying again."}}}, "commit"=>"Create", "action"=>"create", "authenticity_token"=>"s562boG7oXhkhgeurg4C2mKv/vrAgOg5V/zmZjibMZA=", "controller"=>"tickets"} [4;35;1mUser Columns (49.2ms) [0m[0mSHOW FIELDS FROM `users` [0m [4;36;1mUser Load (0.7ms) [0m[0;1mSELECT * FROM `users` WHERE (`users`.`id` = 2) LIMIT 1 [0m [4;35;1mRole Load (0.4ms) [0m[0mSELECT `roles`.* FROM `roles` INNER JOIN `assignments` ON `roles`.id = `assignments`.role_id WHERE ((`assignments`.user_id = 2)) [0m [4;36;1mRole Columns (1.2ms) [0m[0;1mSHOW FIELDS FROM `roles` [0m [4;35;1mTicket Columns (1.8ms) [0m[0mSHOW FIELDS FROM `tickets` [0m [4;36;1mNote Columns (1.6ms) [0m[0;1mSHOW FIELDS FROM `notes` [0m [4;35;1mCustomer Columns (1.6ms) [0m[0mSHOW FIELDS FROM `customers` [0m [4;36;1mCustomer Load (0.8ms) [0m[0;1mSELECT * FROM `customers` WHERE (`customers`.`id` = 1) [0m ActionView::TemplateError (Need controller and action!) on line #5 of app/views/ticket_mailer/newticket.erb: 2: 3: A new ticket titled "<%= @ticket.title %>" has been created for you on the Student Helpdesk Portal. 4: 5: You can view your ticket at <%= link_to @ticket %>. 6: 7: You may submit comments on the ticket to provide questions or feedback concerning the ticket. 8: app/views/ticket_mailer/newticket.erb:5 app/controllers/tickets_controller.rb:84:in `create' Rendered rescues/_trace (147.5ms) Rendered rescues/_request_and_response (0.5ms) Rendering rescues/layout (internal_server_error) - >From the sounds of it, it's a routing issue, which seems a bit odd On Mar 21, 2:13 pm, Michael Pavling wrote: > On 21 March 2010 20:03, command0 wrote: > > > The problem I am having, is when I try to create a new ticket, I get > > the error: > > > NoMethodError (undefined method `customer' for nil:NilClass): > > app/models/ticket_mailer.rb:7:in `newticket' > > app/controllers/tickets_controller.rb:84:in `create' > > > Which I know simply put is telling me the customer doesn't exist, > > because customer_id would be nil, so there is no association. But > > there is. > > No, it's telling you that the "ticket" variable (at line 7 of > ticket_mailer.rb) is nil, and NilClass objects don't have a "customer" > method. > > > class TicketMailer < ActionMailer::Base > > def newticket(ticket) > > ticket = @ticket > > subject 'A new ticket has been created for you' > > recipients ticket.customer.email > > from 'helpd...@stevenshenager.edu' > > sent_on Time.now > > end > > I'd assume the problem is caused by the assignment in the first line > of the method; I'd guess it's meant to read: > @ticket = ticket > ..because as it is, it doesn't make much sense to pass in a ticket > parameter and then immediately overwrite it with an instance variable. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: How to create an index page with data from other contollers
Luke Pearce wrote: > Hiya Graham, > > It depends on your setup really but I would say in this case you would > want another controller. > > If you've put all the shared html into partials then on the new index > page you would just need to do a few <%= render :partial => > 'PARTIAL_NAME'%> to pull in the html you need. > > http://api.rubyonrails.org/classes/ActionView/Partials.html > > http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials > > Cheers > Luke Thanks for the advice Luke I'll use a new controller for the index page as some of the other pages don't have partials. Can I ask how I can link the contollers should I include attributes from the other controllers index defs etc, such as myindexcontroller def index @Businesss = Business.all #from the business controller end end cheers, Graham -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Simple Backup???
Maybe I'm stating the obvious, but it seems to suggest that you have simply not backup/copied the public directory, and so your app is picking up public/index.html. If public/index.html exists, just delete it. On Mar 20, 1:33 am, nshenry03 wrote: > I am simply trying to backup a ruby on rails app... I have created an > archive of the entire database and application folders on server A... > I then restore the database and application folders on server B > > Server B is exactly the same as A (same OS, same ruby, gems, etc...) > > However when I go to the site on server B, all I see is: > > Welcome aboard > You’re riding Ruby on Rails! > > I've checked and all of the files are in the folders, the DB has data > in it, I've rebooted apache... > > What else do I need to do? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Using ActionMailer on a controller method
On 21 March 2010 20:03, command0 wrote: > The problem I am having, is when I try to create a new ticket, I get > the error: > > NoMethodError (undefined method `customer' for nil:NilClass): > app/models/ticket_mailer.rb:7:in `newticket' > app/controllers/tickets_controller.rb:84:in `create' > > Which I know simply put is telling me the customer doesn't exist, > because customer_id would be nil, so there is no association. But > there is. No, it's telling you that the "ticket" variable (at line 7 of ticket_mailer.rb) is nil, and NilClass objects don't have a "customer" method. > class TicketMailer < ActionMailer::Base > def newticket(ticket) > ticket = @ticket > subject 'A new ticket has been created for you' > recipients ticket.customer.email > from 'helpd...@stevenshenager.edu' > sent_on Time.now > end I'd assume the problem is caused by the assignment in the first line of the method; I'd guess it's meant to read: @ticket = ticket ..because as it is, it doesn't make much sense to pass in a ticket parameter and then immediately overwrite it with an instance variable. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Using ActionMailer on a controller method
Hi guys (and gals), I have the most strange issue that I just cannot figure out. It doesn't make sense at all why it's happening, and had a fellow Rails developer friend of mine from the UK look at it with me last night, and still couldn't figure it out. Ok, so I have a helpdesk ticketing system wrote in Rails 2.3.5. The app itself has lots of models and controllers, respectively. The 2 models in the app that I'm working with (well 3 considering the mailer model), is Ticket and Customer. My mailer class is called TicketMailer. To make sense of it for you all, Ticket belongs_to Customer, Customer has_many tickets. That's the relationship between the two. Tickets are created from the customer, so a user has to navigate to the customer in the view and click on the create ticket, which nests the customer_id into the ticket, which is saved to the ticket during the create action. With that said, I created the TicketMailer model, and what I am after, is to deliver an e-mail to the customer when a ticket is created. Here is my TicketMailer model: class TicketMailer < ActionMailer::Base def newticket(ticket) ticket = @ticket subject'A new ticket has been created for you' recipients ticket.customer.email from 'helpd...@stevenshenager.edu' sent_onTime.now end # def ticketstatus(sent_at = Time.now) # subject'The status of your ticket has changed' # recipients ticket.customer.email # from 'helpd...@stevenshenager.edu' # sent_onsent_at # end end The other method is commented out for now, as it hasn't been implemented, and so I will fight that battle later... Here is the view of the e-mail, titled newticket.erb: - Hello <%= ticket.customer.first_name %>, A new ticket titled "<%= ticket.title %>" has been created for you on the Student Helpdesk Portal. You can view your ticket at <%= link_to ticket %>. You may submit comments on the ticket to provide questions or feedback concerning the ticket. As always, feel free to call us anytime at 1-866-888-3768, and we will be happy to help. Thank you for using the Student Helpdesk Portal, and have a great day. Regards, The Helpdesk Team And here is my create action in my Tickets controller: def create @ticket = Ticket.new(params[:ticket]) @ticket.notes.first.user_id = current_user.id TicketMailer.deliver_newticket(@ticket) logger.debug("@@@ - Customer email is #...@ticket.customer.email}") respond_to do |format| if @ticket.save TicketMailer.create_newticket(@ticket) TicketMailer.deliver_newticket(@ticket) flash[:notice] = 'Ticket was successfully created.' format.html { redirect_to(@ticket) } format.xml { render :xml => @cticket, :status => :created, :location => @ticket } else format.html { render :action => "new" } format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity } end end end For clarification, I placed the deliver above if @ticket.save for now to get it working, since I don't want new tickets getting created before the mailer is working. The problem I am having, is when I try to create a new ticket, I get the error: NoMethodError (undefined method `customer' for nil:NilClass): app/models/ticket_mailer.rb:7:in `newticket' app/controllers/tickets_controller.rb:84:in `create' Which I know simply put is telling me the customer doesn't exist, because customer_id would be nil, so there is no association. But there is. Here are the params that get passed into the create action. Not the logger.debug message I put which just reiterates that the exact attribute I'm calling is available. Processing TicketsController#create (for 127.0.0.1 at 2010-03-21 00:05:11) [POST] Parameters: {"ticket"=>{"platform_id"=>"", "title"=>"Testing mailer", "app_version"=>"", "app_id"=>"", "category_id"=>"5", "user_id"=>"2", "os_version"=>"", "status_id"=>"1", "desc"=>"Seeing if the mailer works.", "customer_id"=>"1", "notes_attributes"=>{"0"=>{"body"=>"Testing mailer."}}}, "commit"=>"Create", "action"=>"create", "authenticity_token"=>"lFPGXK8LdqYArXPb02lvF9RSywEiK1HehoPQv7etE/c=", "controller"=>"tickets"} [4;36;1mUser Columns (3.4ms) [0m[0;1mSHOW FIELDS FROM `users` [0m [4;35;1mUser Load (0.6ms) [0m[0mSELECT * FROM `users` WHERE (`users`.`id` = 2) LIMIT 1 [0m [4;36;1mRole Load (1.5ms) [0m[0;1mSELECT `roles`.* FROM `roles` INNER JOIN `assignments` ON `roles`.id = `assignments`.role_id WHERE ((`assignments`.user_id = 2)) [0m [4;35;1mRole Columns (5.4ms) [0m[0mSHOW FIELDS FROM `roles` [0m [4;36;1mTicket Columns (2.1ms) [0m[0;1mSHOW FIELDS FROM `tickets` [0m [4;35;1mNote Columns (1.9ms) [0m[0mSHOW FIELDS FROM `notes` [0m [4;36;1mCustomer Columns (1.9ms) [0m[0;1mS
[Rails] Re: Error in the code Doube Render (colins')
Frederick Cheung wrote: > On Mar 21, 7:00�pm, Tiger Big one wrote: >> > In the case where the request is a post request and if the user is > logged in successfully you are calling redirect_to :action => 'index' > twice > > Fred I wrote the same code (exactly the same code)...twice for def login and def register. Does that matter? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Error in the code Doube Render (colins')
On Mar 21, 7:00 pm, Tiger Big one wrote: > Hi everyone, i followed colins example and it worked perfectly but now i > get this error > > ActionController::DoubleRenderError in UserController#login > > Render and/or redirect were called multiple times in this action. Please > note that you may only call render OR redirect, and at most once per > action. Also note that neither redirect nor render terminate execution > of the action, so if you want to exit an action after redirecting, you > need to do something like "redirect_to(...) and return". > In the case where the request is a post request and if the user is logged in successfully you are calling redirect_to :action => 'index' twice Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Ruby on Rails tutorials for beginners are available here
Thanks Mark and Max On Mar 20, 10:40 pm, Mark McConachie wrote: > Great blog, I have forwarded this to some beginners I know. > > On Mar 19, 3:52 pm, pankaj wrote: > > > Hello Everyone, > > I have started my blog athttp://railsguru.org. > > Besides other stuff on Rails, the main focus of the site will be to > > help beginners to learn Ruby and Rails and build the fundamentals. > > > Regards, > > Pankaj Bhageria, > > Tech Lead, Sumeru Software > > Solutions.http://www.railsguru.orghttp://www.sumeru.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Error in the code Doube Render (colins')
Hi everyone, i followed colins example and it worked perfectly but now i get this error ActionController::DoubleRenderError in UserController#login Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". I feel that something is wrong with this code def login @title = "Login - Books" if request.post? @user = User.new(params[:user]) user = User.find_by_screen_name_and_password(@user.screen_name, @user.password) if user session[:user_id] = user.id flash[:notice] = "User #{user.screen_name} logged in" redirect_to :action => "index" else # Don't show the password in the view @user.password = nil flash[:notice] = "Invalid email/password combination" end end if session[:user_id] flash[:notice] = "Already registed and logged in! You cannot view the register or login!" redirect_to :action => :index end end /// if session[:user_id] flash[:notice] = "Already registed and logged in! You cannot view the register or login!" redirect_to :action => :index end /// what this does, is if session ID is found, then it takes the login page back to index...can someone help me please :( -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: MySQL Installation Issues
Colin Law wrote: > ri and rdoc are just for documentation of the gem. Google them to > find details. Not having them will not affect the operation of the > gem. > > Colin Thanks Colin. I quickly found that out. I've posted instructions for resolving this issue at MySQL: http://forums.mysql.com/read.php?116,359591,359591#msg-359591 The described process determines vital paths for successful installation on potentially any system. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3: Update responding with empty json
On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch wrote: > Hi all! > > I'm playing with Rails 3, and on one of my controllers I have the > following update method defined: > > def update >@category = @user.categories.find(params[:id]) >@category.update_attributes(params[:ecategory]) >@category.save >respond_with @category > end > > Fabio, you should not be calling save within the update action because 'update_attributes' calls save implicitly. Thus, you should do something like the following: class CategoriesController < ApplicationController::Base respond_to :html, :json def update @category = @user.categories.find( params[:id] ) if @category.update_attributes( params[:category] ) flash[:notice] = 'Category was successfully created.' end respond_with( @category ) end end Good luck, -Conrad I'm using Jquery to interact with the controllers, and when I do an > ajax PUT, the update action is correctly executed (the fields are > updated), but the action returns an empty JSON object, which causes > the Jquery ajax function to fall into an error. > > I'm I doing something wrong? > > Thank you all, > Fabio. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Calculate Probability?
The Sun, 21 Mar 2010 17:12:02 +0100, Heinz Strunk wrote: > Hello, > > I'm working with probability and Ruby doesn't really does as I want. > Just to make it easier to understand I'll focus on the problem. > > I have some event that should occur in 20% of all events. I thought > I'd make it easy by just using rand like following: > num = 20 - rand(100) > if(num > 0) >do_stuff > end > > But "do_stuff" is by far not being called as often as I would like it > to. Is there any method or something that is more accurate with that > kind of stuff? As said in another answer, this is convoluted code, simply testing rand(100) < 20 is ok. To answer your original question, rand implementations don't do what most developers think they do : they are pseudo-random number generators and the randomness is not guaranteed for only one call to rand in a whole program. If you try to get a random value only once in your program, you should feed the number generator a truly random value (for example read 4 bytes from /dev/urandom on a modern Unix box and feed them as an Integer to the generator through Kernel.srand). Lionel -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: Logging out feature
Thank you very much Jeffrey and Colin... :) It worked perfectly and change the != to = -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Need very simple help...
Colin Law wrote: > On 21 March 2010 15:25, Jagmit Gabba wrote: >> � � �flash[:notice] = "Please Login to view this page, or Register if >> flash message is displayed. >> >> When the user is logged in, i want it to redirect the "user/register" >> and "user/login" to the "user/index", and if they are NOT logged in, >> they can view them. I have done this with the IF command in my menu but >> physically they can type the address aka user/register or user/login and >> view them again. > > You have already shown us how you redirect from index to login if the > user is not logged in. You are asking how to redirect from register > and login if not logged in. Just use basically the same technique but > the test will be the the other way round ('if' instead of 'unless'). > > Colin Thank you very much Colin, Simple code: if session[:user_id] flash[:notice] = "Already registed and logged in! You cannot view the register or login!" redirect_to :action => :index end end Thank you for making me understand :D -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Calculate Probability?
Quoting Jeffrey L. Taylor : [snip] > I dumped the first line into irb and tried it. It looked like do_stuff > wouldn't be called often enough, so I actually counted the occurrences and > crunched the numbers. They were within a reasonable distance of 1 in 5. I > suggest actually running the code and counting the occurrences. I suspect > you'll find that 20% is less often then it seems. > Oops, change to "less often than it seems." Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Calculate Probability?
Quoting Heinz Strunk : > Hello, > > I'm working with probability and Ruby doesn't really does as I want. > Just to make it easier to understand I'll focus on the problem. > > I have some event that should occur in 20% of all events. I thought I'd > make it easy by just using rand like following: > num = 20 - rand(100) > if(num > 0) >do_stuff > end > > But "do_stuff" is by far not being called as often as I would like it > to. Is there any method or something that is more accurate with that > kind of stuff? > The code looks correct, though a bit hard to understand. If it were my code, I might refactor it like this: do_stuff if rand(100) < 20 I dumped the first line into irb and tried it. It looked like do_stuff wouldn't be called often enough, so I actually counted the occurrences and crunched the numbers. They were within a reasonable distance of 1 in 5. I suggest actually running the code and counting the occurrences. I suspect you'll find that 20% is less often then it seems. HTH, Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Logging out feature
On 21 March 2010 15:59, Jagmit Gabba wrote: > Logging out feature, > > Code: > > def logout > �...@title = "Login - Books" > > session[:user_id] != nil Do you mean session[:user_id] = nil Colin > flash[:notice] = "You have sucessfully been logged out !" > redirect_to :controller => :books, :action => :index > end > end > > ^^when this is run, it logs the user out (nill) and displays you have > successfully been logged out, > > Code v2: > def logout > �...@title = "Login - Books" > > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out > #...@user.screen_name} !" > redirect_to :controller => :books, :action => :index > end > end > > ^^what i was hoping this would do is to display the users name as well, > (this is another task), i understand the session but how can i bring the > session back while the session is nill :S > > thanks once again mates, > > Jagmit Gabba > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Logging out feature
Quoting Jagmit Gabba : > Jeffrey L. Taylor wrote: > > Quoting Jagmit Gabba : > >>end > >> flash[:notice] = "You have sucessfully been logged out > >> #...@user.screen_name} !" > >> redirect_to :controller => :books, :action => :index > >> end > >> end > >> > >> ^^what i was hoping this would do is to display the users name as well, > >> (this is another task), i understand the session but how can i bring the > >> session back while the session is nill :S > >> > > > > Where is the instance variable @user set? If it were my code, I'd do > > something like this: > > > > def logout > >@title = "Login - Books" > > > >name = User.find(session[:user_id]) > >session[:user_id] != nil > >flash[:notice] = "You have sucessfully been logged out #{name}!" > >redirect_to :controller => :books, :action => :index > > end > > > > HTH, > > Jeffrey > > Good afternoon friend, > > Your code doesnt seem to be working as it gives me a SyntaxError, at the > end i added another end cause of the nill, it seems to work but the only > thing which is displayed is "You have successfully been logged out #!" > just that, no username. Oops, change: name = User.find(session[:user_id]) To: name = User.find(session[:user_id], :select => 'screen_name').screen_name Or maybe clearer: def logout @title = "Login - Books" user = User.find(session[:user_id], :select => 'screen_name') session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out #{user.screen_name}!" redirect_to :controller => :books, :action => :index end And yes, you need the additional end to close the class. Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Calculate Probability?
The code snippet seems OK to me, although the code you have in the if block will happen 80% not 20% of the time, and it could be made a bit "slimmer". But you say it happens less than 20%? Tried this on by Ubuntu box with Ruby 1.8.7: irb(main):021:0> counter = 0 => 0 irb(main):022:0> 100.times{counter += 1 if rand(100) < 20} => 100 irb(main):023:0> puts String(Float(counter)/1) + "%" 20.0002% => nil So, given a million iterations, it seems to work OK, and gives the expected result of close to 20% hitrate. But if you still have problems, then I'm at a loss Some platform specific seeding issue perhaps? Well, hope this helps... :o) Regards, Rolf On Sun, Mar 21, 2010 at 5:12 PM, Heinz Strunk wrote: > Hello, > > I'm working with probability and Ruby doesn't really does as I want. > Just to make it easier to understand I'll focus on the problem. > > I have some event that should occur in 20% of all events. I thought I'd > make it easy by just using rand like following: > num = 20 - rand(100) > if(num > 0) > do_stuff > end > > But "do_stuff" is by far not being called as often as I would like it > to. Is there any method or something that is more accurate with that > kind of stuff? > > Thanks in advance! > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Need very simple help...
On 21 March 2010 15:25, Jagmit Gabba wrote: > I have several questions and i need clear understanding on how i should > approach them, my target is for creating something called "fakebook", > facebooks copy but not going live at all (uni project). > > Security Question > This is the code that helps me protect my "user/index".. > > private > def protect > unless session[:user_id] > flash[:notice] = "Please Login to view this page, or Register if > you do not have an account!" > redirect_to :action => :login > return false > end > end > > It works perfectly, as it checks for the session ID and when it finds > the user is logged in, he can view the user/index (another code is > placed on top with this). > Otherwise, they cannot view it and it takes them to the login page and a > flash message is displayed. > > When the user is logged in, i want it to redirect the "user/register" > and "user/login" to the "user/index", and if they are NOT logged in, > they can view them. I have done this with the IF command in my menu but > physically they can type the address aka user/register or user/login and > view them again. You have already shown us how you redirect from index to login if the user is not logged in. You are asking how to redirect from register and login if not logged in. Just use basically the same technique but the test will be the the other way round ('if' instead of 'unless'). Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Rails 3: Update responding with empty json
Hi all! I'm playing with Rails 3, and on one of my controllers I have the following update method defined: def update @category = @user.categories.find(params[:id]) @category.update_attributes(params[:ecategory]) @category.save respond_with @category end I'm using Jquery to interact with the controllers, and when I do an ajax PUT, the update action is correctly executed (the fields are updated), but the action returns an empty JSON object, which causes the Jquery ajax function to fall into an error. I'm I doing something wrong? Thank you all, Fabio. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Logging out feature
Jeffrey L. Taylor wrote: > Quoting Jagmit Gabba : >>end >> flash[:notice] = "You have sucessfully been logged out >> #...@user.screen_name} !" >> redirect_to :controller => :books, :action => :index >> end >> end >> >> ^^what i was hoping this would do is to display the users name as well, >> (this is another task), i understand the session but how can i bring the >> session back while the session is nill :S >> > > Where is the instance variable @user set? If it were my code, I'd do > something like this: > > def logout >@title = "Login - Books" > >name = User.find(session[:user_id]) >session[:user_id] != nil >flash[:notice] = "You have sucessfully been logged out #{name}!" >redirect_to :controller => :books, :action => :index > end > > HTH, > Jeffrey Good afternoon friend, Your code doesnt seem to be working as it gives me a SyntaxError, at the end i added another end cause of the nill, it seems to work but the only thing which is displayed is "You have successfully been logged out #!" just that, no username. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
NEVER MIND. I was being an idiot. I just deleted the old migration file that was causing the problems; and then created a new migration file to get the new stuff in.. Thanks Guys, -Joe On Mar 21, 4:25 pm, yout...@dev-hq.co.uk wrote: > Ok, So I figure I have to roll the database back and then migrate it > again. > > However it just isnt doing anything when I call "rake db:rollback", or > even specify a STEP: > > >rake db:rollback STEP=4 > > (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog)>rake > db:rollback STEP=10 > > (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog)>rake > db:migrate > > (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) > == CreateCategories: migrating > === > -- create_table(:categories) > rake aborted! > An error has occurred, this and all later migrations canceled: > > SQLite3::SQLException: table "categories" already exists: CREATE TABLE > "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" > varchar(255), "image" varchar(255), "created_at" datetime, > "updated_at" datetime) > > (See full trace by running task with --trace) > > I just cant figure out why it wont rollback... > > Please Help, > > Thanks In Advance, > > Joe > > On Mar 21, 2:26 pm, Colin Law wrote: > > > On 21 March 2010 13:40, wrote: > > > > Ok, I seem to have a problem already. > > > > So first of all with these things, can I just change it in db/migrate/ > > > WhateverFile.rb ? > > > Then when I have changed it how do I put these changes into action? > > > I suggest you have a look at the rails guides > > athttp://guides.rubyonrails.org/. Start with Getting Started, not > > surprisingly, then the next one is Database Migrations which should > > sort out your current problems. Then move on and work you way through > > the others. > > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > > Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Ok, So I figure I have to roll the database back and then migrate it again. However it just isnt doing anything when I call "rake db:rollback", or even specify a STEP: >rake db:rollback STEP=4 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:rollback STEP=10 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:migrate (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) == CreateCategories: migrating === -- create_table(:categories) rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) I just cant figure out why it wont rollback... Please Help, Thanks In Advance, Joe On Mar 21, 2:26 pm, Colin Law wrote: > On 21 March 2010 13:40, wrote: > > > Ok, I seem to have a problem already. > > > So first of all with these things, can I just change it in db/migrate/ > > WhateverFile.rb ? > > Then when I have changed it how do I put these changes into action? > > I suggest you have a look at the rails guides > athttp://guides.rubyonrails.org/. Start with Getting Started, not > surprisingly, then the next one is Database Migrations which should > sort out your current problems. Then move on and work you way through > the others. > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Ok, So I figure I have to roll the database back and then migrate it again. However it just isnt doing anything when I call "rake db:rollback", or even specify a STEP: >rake db:rollback STEP=4 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:rollback STEP=10 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:migrate (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) == CreateCategories: migrating === -- create_table(:categories) rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) I just cant figure out why it wont rollback... Please Help, Thanks In Advance, Joe On Mar 21, 2:26 pm, Colin Law wrote: > On 21 March 2010 13:40, wrote: > > > Ok, I seem to have a problem already. > > > So first of all with these things, can I just change it in db/migrate/ > > WhateverFile.rb ? > > Then when I have changed it how do I put these changes into action? > > I suggest you have a look at the rails guides > athttp://guides.rubyonrails.org/. Start with Getting Started, not > surprisingly, then the next one is Database Migrations which should > sort out your current problems. Then move on and work you way through > the others. > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Logging out feature
Quoting Jagmit Gabba : > Logging out feature, > > Code: > > def logout > @title = "Login - Books" > > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out !" > redirect_to :controller => :books, :action => :index >end > end > > ^^when this is run, it logs the user out (nill) and displays you have > successfully been logged out, > > Code v2: > def logout > @title = "Login - Books" > > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out > #...@user.screen_name} !" > redirect_to :controller => :books, :action => :index > end > end > > ^^what i was hoping this would do is to display the users name as well, > (this is another task), i understand the session but how can i bring the > session back while the session is nill :S > Where is the instance variable @user set? If it were my code, I'd do something like this: def logout @title = "Login - Books" name = User.find(session[:user_id]) session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out #{name}!" redirect_to :controller => :books, :action => :index end HTH, Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Calculate Probability?
Hello, I'm working with probability and Ruby doesn't really does as I want. Just to make it easier to understand I'll focus on the problem. I have some event that should occur in 20% of all events. I thought I'd make it easy by just using rand like following: num = 20 - rand(100) if(num > 0) do_stuff end But "do_stuff" is by far not being called as often as I would like it to. Is there any method or something that is more accurate with that kind of stuff? Thanks in advance! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Logging out feature
Logging out feature, Code: def logout @title = "Login - Books" session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out !" redirect_to :controller => :books, :action => :index end end ^^when this is run, it logs the user out (nill) and displays you have successfully been logged out, Code v2: def logout @title = "Login - Books" session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out #...@user.screen_name} !" redirect_to :controller => :books, :action => :index end end ^^what i was hoping this would do is to display the users name as well, (this is another task), i understand the session but how can i bring the session back while the session is nill :S thanks once again mates, Jagmit Gabba -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Need very simple help...
Leonardo Mateo wrote: > On Sun, Mar 21, 2010 at 12:25 PM, Jagmit Gabba > wrote: >> � � �flash[:notice] = "Please Login to view this page, or Register if >> flash message is displayed. >> > I'd strongly suggest you to take a look at Authlogic[1] gem. Even when > this is a very simple/personal project, and implement this gem might > look too much overhead for you, you'll get very interesting concepts > for authentication. > > [1]http://github.com/binarylogic/authlogic > > Hope it helps. > > > -- > Leonardo Mateo. > There's no place like ~ Thank you for your reply, i am a very basic student and i need to take it one bit a time. This was small homework set, ill have to take it small steps before i can leap. Would love a simple answer so i can understand it. Thanks once again, Jagmit Gabba -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
And remember to use http://railscasts.com/ Great for getting started. /SG On Mar 21, 3:26 pm, Colin Law wrote: > On 21 March 2010 13:40, wrote: > > > Ok, I seem to have a problem already. > > > So first of all with these things, can I just change it in db/migrate/ > > WhateverFile.rb ? > > Then when I have changed it how do I put these changes into action? > > I suggest you have a look at the rails guides > athttp://guides.rubyonrails.org/. Start with Getting Started, not > surprisingly, then the next one is Database Migrations which should > sort out your current problems. Then move on and work you way through > the others. > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Need very simple help...
On Sun, Mar 21, 2010 at 12:25 PM, Jagmit Gabba wrote: > I have several questions and i need clear understanding on how i should > approach them, my target is for creating something called "fakebook", > facebooks copy but not going live at all (uni project). > > Security Question > This is the code that helps me protect my "user/index".. > > private > def protect > unless session[:user_id] > flash[:notice] = "Please Login to view this page, or Register if > you do not have an account!" > redirect_to :action => :login > return false > end > end > > It works perfectly, as it checks for the session ID and when it finds > the user is logged in, he can view the user/index (another code is > placed on top with this). > Otherwise, they cannot view it and it takes them to the login page and a > flash message is displayed. > > When the user is logged in, i want it to redirect the "user/register" > and "user/login" to the "user/index", and if they are NOT logged in, > they can view them. I have done this with the IF command in my menu but > physically they can type the address aka user/register or user/login and > view them again. > > How can i redirect this? > > thank you for your help! > I'd strongly suggest you to take a look at Authlogic[1] gem. Even when this is a very simple/personal project, and implement this gem might look too much overhead for you, you'll get very interesting concepts for authentication. [1]http://github.com/binarylogic/authlogic Hope it helps. -- Leonardo Mateo. There's no place like ~ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Need very simple help...
I have several questions and i need clear understanding on how i should approach them, my target is for creating something called "fakebook", facebooks copy but not going live at all (uni project). Security Question This is the code that helps me protect my "user/index".. private def protect unless session[:user_id] flash[:notice] = "Please Login to view this page, or Register if you do not have an account!" redirect_to :action => :login return false end end It works perfectly, as it checks for the session ID and when it finds the user is logged in, he can view the user/index (another code is placed on top with this). Otherwise, they cannot view it and it takes them to the login page and a flash message is displayed. When the user is logged in, i want it to redirect the "user/register" and "user/login" to the "user/index", and if they are NOT logged in, they can view them. I have done this with the IF command in my menu but physically they can type the address aka user/register or user/login and view them again. How can i redirect this? thank you for your help! -Guru -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Rail Quickstart Guide: Always receiving "template missing" errors.
If you read carefully http://guides.rubyonrails.org/getting_started.html you can find that in your routes.rb file have to be following lines map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' I also new in RoR and I don't know why you wrote "map.connect 'home/ index', :controller => 'home', :action => 'index' " in your routes.rb. and what it should be mean. We both need to read more about routes in RoR. On Mar 20, 2:34 am, Stone wrote: > Thanks for your time. I'm almost sure there is no typo on my part. I'm > actually starting to think there's something wrong with the > environment as I have created small ror apps before without any issues > and am somewhat experiences w/ rails. Having gone through the rails > quickstart guide again, I have the same issue w/ home controller. > > home_controller.rb -- > class HomeController < ApplicationController > def index > end > end > > routes.rb - > ActionController::Routing::Routes.draw do |map| > # The priority is based upon order of creation: first created -> > highest priority. > map.connect 'home/index', :controller => 'home', :action => 'index' > > # Sample of regular route: > # map.connect 'products/:id', :controller => 'catalog', :action => > 'view' > # Keep in mind you can assign values other than :controller > and :action > > # Sample of named route: > # map.purchase 'products/:id/purchase', :controller => > 'catalog', :action => 'purchase' > # This route can be invoked with purchase_url(:id => product.id) > > # Sample resource route (maps HTTP verbs to controller actions > automatically): > # map.resources :products > > # Sample resource route with options: > # map.resources :products, :member => { :short => :get, :toggle > => :post }, :collection => { :sold => :get } > > # Sample resource route with sub-resources: > # map.resources :products, :has_many => > [ :comments, :sales ], :has_one => :seller > > # Sample resource route with more complex sub-resources > # map.resources :products do |products| > # products.resources :comments > # products.resources :sales, :collection => { :recent => :get } > # end > > # Sample resource route within a namespace: > # map.namespace :admin do |admin| > # # Directs /admin/products/* to Admin::ProductsController (app/ > controllers/admin/products_controller.rb) > # admin.resources :products > # end > > # You can have the root of your site routed with map.root -- just > remember to delete public/index.html. > # map.root :controller => "welcome" > > # See how all your routes lay out with "rake routes" > > # Install the default routes as the lowest priority. > # Note: These default routes make all actions in every controller > accessible via GET requests. You should > # consider removing or commenting them out if you're using named > routes and resources. > map.root :controller => "home" > end > > index.html.erb - > Home#index > Find me in app/views/home/index.html.erb > > Again, I am following the rails quickstart guide for 2.3 verbatim and > still receiving this error: > "Processing HomeController#index (for 127.0.0.1 at 2010-03-19 > 15:42:14) [GET] > ActionView::MissingTemplate (Missing template home/index.erb in view > path app/views): > Rendering rescues/layout (internal_server_error)" > > Any help greatly appreciated > Thanks, > Stone -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Changing Scafflolds
On 21 March 2010 13:40, wrote: > Ok, I seem to have a problem already. > > So first of all with these things, can I just change it in db/migrate/ > WhateverFile.rb ? > Then when I have changed it how do I put these changes into action? I suggest you have a look at the rails guides at http://guides.rubyonrails.org/. Start with Getting Started, not surprisingly, then the next one is Database Migrations which should sort out your current problems. Then move on and work you way through the others. The ones on ActiveRecord Associations and Debugging are compulsory reading. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: How to initially hide a drop-down control and have an image control make it visible
On 21 March 2010 10:49, RichardOnRails wrote: > Hi Colin, > > Your "check the HTML" tip is *great* ... it's now in my debugging > arsenal. Another tip is to install the Html Validator add-on to Firefox and it will automatically validate your pages as you develop, this often shows up the reason why something is not working as you expect. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Ok, I seem to have a problem already. So first of all with these things, can I just change it in db/migrate/ WhateverFile.rb ? Then when I have changed it how do I put these changes into action? Also I cant seem to find how this could help me solve the error: rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) Although I assume it could in some way (since it has to do with the database, and rake etc).. Please Help, Thanks In Advance, Joe On Mar 21, 1:11 pm, yout...@dev-hq.co.uk wrote: > Aha, thanks! ill look into this (I really dont know any of the > terminology, when I created the stuff I saw the word scaffold and > assumed this was what to call it :P) > > If I have any further problems ill ask. > > Thanks, > > Joe > > On Mar 21, 1:02 pm, Michael Pavling wrote: > > > On 21 March 2010 12:02, wrote: > > > > For example if I created a forum with RoR and decided to have a forum, > > > thread, and post scaffold, and they each has their own properties; > > > > rake aborted! > > > An error has occurred, this and all later migrations canceled: > > > You've got some terminology problems there, that are confusing things > > a little. What you're calling "scaffolds" are really "migrations". > > > "Scaffolding" is the combination of views, migrations, models and > > controllers that Rails can create for you to give you a bootstrap into > > a working application. > > > By the sounds of it, you need to use "add_column" in your new migration. > > Have a look at some of the resources found through Google, or at p.71 > > of the "Agile Web Development With Rails" > > book.http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Ok, I seem to have a problem already. So first of all with these things, can I just change it in db/migrate/ WhateverFile.rb ? Then when I have changed it how do I put these changes into action? Also I cant seem to find how this could help me solve the error: rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) Although I assume it could in some way (since it has to do with the database, and rake etc).. Please Help, Thanks In Advance, Joe On Mar 21, 1:11 pm, yout...@dev-hq.co.uk wrote: > Aha, thanks! ill look into this (I really dont know any of the > terminology, when I created the stuff I saw the word scaffold and > assumed this was what to call it :P) > > If I have any further problems ill ask. > > Thanks, > > Joe > > On Mar 21, 1:02 pm, Michael Pavling wrote: > > > On 21 March 2010 12:02, wrote: > > > > For example if I created a forum with RoR and decided to have a forum, > > > thread, and post scaffold, and they each has their own properties; > > > > rake aborted! > > > An error has occurred, this and all later migrations canceled: > > > You've got some terminology problems there, that are confusing things > > a little. What you're calling "scaffolds" are really "migrations". > > > "Scaffolding" is the combination of views, migrations, models and > > controllers that Rails can create for you to give you a bootstrap into > > a working application. > > > By the sounds of it, you need to use "add_column" in your new migration. > > Have a look at some of the resources found through Google, or at p.71 > > of the "Agile Web Development With Rails" > > book.http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Ok, I seem to have a problem already. So first of all with these things, can I just change it in db/migrate/ WhateverFile.rb ? Then when I have changed it how do I put these changes into action? Also I cant seem to find how this could help me solve the error: rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) Although I assume it could in some way (since it has to do with the database, and rake etc).. Please Help, Thanks In Advance, Joe On Mar 21, 1:11 pm, yout...@dev-hq.co.uk wrote: > Aha, thanks! ill look into this (I really dont know any of the > terminology, when I created the stuff I saw the word scaffold and > assumed this was what to call it :P) > > If I have any further problems ill ask. > > Thanks, > > Joe > > On Mar 21, 1:02 pm, Michael Pavling wrote: > > > On 21 March 2010 12:02, wrote: > > > > For example if I created a forum with RoR and decided to have a forum, > > > thread, and post scaffold, and they each has their own properties; > > > > rake aborted! > > > An error has occurred, this and all later migrations canceled: > > > You've got some terminology problems there, that are confusing things > > a little. What you're calling "scaffolds" are really "migrations". > > > "Scaffolding" is the combination of views, migrations, models and > > controllers that Rails can create for you to give you a bootstrap into > > a working application. > > > By the sounds of it, you need to use "add_column" in your new migration. > > Have a look at some of the resources found through Google, or at p.71 > > of the "Agile Web Development With Rails" > > book.http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Ok, I seem to have a problem already. So first of all with these things, can I just change it in db/migrate/ WhateverFile.rb ? Then when I have changed it how do I put these changes into action? Also I cant seem to find how this could help me solve the error: rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) Although I assume it could in some way (since it has to do with the database, and rake etc).. Please Help, Thanks In Advance, Joe On Mar 21, 1:11 pm, yout...@dev-hq.co.uk wrote: > Aha, thanks! ill look into this (I really dont know any of the > terminology, when I created the stuff I saw the word scaffold and > assumed this was what to call it :P) > > If I have any further problems ill ask. > > Thanks, > > Joe > > On Mar 21, 1:02 pm, Michael Pavling wrote: > > > On 21 March 2010 12:02, wrote: > > > > For example if I created a forum with RoR and decided to have a forum, > > > thread, and post scaffold, and they each has their own properties; > > > > rake aborted! > > > An error has occurred, this and all later migrations canceled: > > > You've got some terminology problems there, that are confusing things > > a little. What you're calling "scaffolds" are really "migrations". > > > "Scaffolding" is the combination of views, migrations, models and > > controllers that Rails can create for you to give you a bootstrap into > > a working application. > > > By the sounds of it, you need to use "add_column" in your new migration. > > Have a look at some of the resources found through Google, or at p.71 > > of the "Agile Web Development With Rails" > > book.http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Aha, thanks! ill look into this (I really dont know any of the terminology, when I created the stuff I saw the word scaffold and assumed this was what to call it :P) If I have any further problems ill ask. Thanks, Joe On Mar 21, 1:02 pm, Michael Pavling wrote: > On 21 March 2010 12:02, wrote: > > > For example if I created a forum with RoR and decided to have a forum, > > thread, and post scaffold, and they each has their own properties; > > > rake aborted! > > An error has occurred, this and all later migrations canceled: > > You've got some terminology problems there, that are confusing things > a little. What you're calling "scaffolds" are really "migrations". > > "Scaffolding" is the combination of views, migrations, models and > controllers that Rails can create for you to give you a bootstrap into > a working application. > > By the sounds of it, you need to use "add_column" in your new migration. > Have a look at some of the resources found through Google, or at p.71 > of the "Agile Web Development With Rails" > book.http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Aha, thanks! ill look into this (I really dont know any of the terminology, when I created the stuff I saw the word scaffold and assumed this was what to call it :P) If I have any further problems ill ask. Thanks, Joe On Mar 21, 1:02 pm, Michael Pavling wrote: > On 21 March 2010 12:02, wrote: > > > For example if I created a forum with RoR and decided to have a forum, > > thread, and post scaffold, and they each has their own properties; > > > rake aborted! > > An error has occurred, this and all later migrations canceled: > > You've got some terminology problems there, that are confusing things > a little. What you're calling "scaffolds" are really "migrations". > > "Scaffolding" is the combination of views, migrations, models and > controllers that Rails can create for you to give you a bootstrap into > a working application. > > By the sounds of it, you need to use "add_column" in your new migration. > Have a look at some of the resources found through Google, or at p.71 > of the "Agile Web Development With Rails" > book.http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Changing Scafflolds
On 21 March 2010 12:02, wrote: > For example if I created a forum with RoR and decided to have a forum, > thread, and post scaffold, and they each has their own properties; > > rake aborted! > An error has occurred, this and all later migrations canceled: > You've got some terminology problems there, that are confusing things a little. What you're calling "scaffolds" are really "migrations". "Scaffolding" is the combination of views, migrations, models and controllers that Rails can create for you to give you a bootstrap into a working application. By the sounds of it, you need to use "add_column" in your new migration. Have a look at some of the resources found through Google, or at p.71 of the "Agile Web Development With Rails" book. http://www.google.co.uk/search?q=rails+migration+add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
For example if I created a forum with RoR and decided to have a forum, thread, and post scaffold, and they each has their own properties; Lets say the forum scaffold was made with these parameters "forum name:string number:integer". However if I wanted to add another property to the forum scaffold (for example if I wanted to add "password:string") how would I do this? At the moment I have something similar to this (well its different, but never the less uses scaffolds kind of like this) and I need to add a new property. Ive tried creating over the top of it with its already existing parameters plus the ones I want to add (for example "forum name:string number:integer password:string") however when I do this I then get this error when I attempt to migrate the database (categories is the scaffold I'm trying to add properties to): rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) I really need to be able to: 1)Get past this error. 2)Figure out how to add properties to scaffolds. Thanks In Advance, Joe On Mar 21, 11:53 am, gundestrup wrote: > Don't you just use the scaffold, as a bases, and the create the rest > manual? > > What is your exact problem: > What have you done? > What are you missing/trying to do? > > Give concrete examples. > > /SG > > On Mar 21, 9:06 am, yout...@dev-hq.co.uk wrote: > > > Basically I've been creating various RoR (ruby on rails) applications > > and I cant figure out how to add properties to an already existing > > scaffold; I have ended up destroying and messing up two projects that > > I've worked hard on so far in trying to do this and realised I need > > some help trying to edit these. > > > Please Help, > > > Joe -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Changing Scafflolds
Don't you just use the scaffold, as a bases, and the create the rest manual? What is your exact problem: What have you done? What are you missing/trying to do? Give concrete examples. /SG On Mar 21, 9:06 am, yout...@dev-hq.co.uk wrote: > Basically I've been creating various RoR (ruby on rails) applications > and I cant figure out how to add properties to an already existing > scaffold; I have ended up destroying and messing up two projects that > I've worked hard on so far in trying to do this and realised I need > some help trying to edit these. > > Please Help, > > Joe -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: How to initially hide a drop-down control and have an image control make it visible
Hi Colin, Your "check the HTML" tip is *great* ... it's now in my debugging arsenal. > comma missing That was a tip on my img-base code. I'll get back to that because I like the down-arrow image better that ShowList button version, which is close to working. My last next-to-last problem in this code is that the ShowList button doesn't toggle the visibility of the vendor_droplist. My guess is that the onclick value is RJS that should have been translated into JavaScript at this point. My final problem is how to add on-click code to the return vendor items so that clicking any of them toggles (or hides: same effect in this context) the vendor_droplist. But I can probably do this on my own correctly. Below is the ERB code and the generated HTML for the vendor input. As I've done so often, thank you for looking into my problem. I am learning this stuff steadily so I should post questions much less frequently in just a few weeks. Best wishes, Richard Vendor input code = <%= f.label :vendor %> <%= f.text_field :vendor %> <%= button_to_function("ShowList", % ) %> <%= select_tag "test", options_for_select(@current_vendors.collect { |v| v.nickname }), {:multiple => true} %> Generated HTML Vendor IBM Fed Ex On Mar 21, 5:04 am, Colin Law wrote: > On 21 March 2010 04:07, RichardOnRails > > wrote: > > Hi, > > > I've got the following code in my attempt to provide the subject > > functionality, lines 20-29 in view: > > > <%= image_tag "DownArrow.jpg" options = > > { onclick=page["vendor_droplist"].show } %> > > I don't know whether it is still relevant after your later emails but > the problem here is (at least in part) that you are missing a comma > after "DownArrow.jpg" and a > after options = > > Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Changing Scafflolds
Basically I've been creating various RoR (ruby on rails) applications and I cant figure out how to add properties to an already existing scaffold; I have ended up destroying and messing up two projects that I've worked hard on so far in trying to do this and realised I need some help trying to edit these. Please Help, Joe -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Calling a default record for a has_many association
I have a Shop model that has_many Zones (a Zone assigns different pricing to products). I want to save a default Zone for a Shop. This is what I have in my Shop class: has_one :default_zone, :class_name => "Zone" After that, however, I am a bit lost. I know I can manually set shop.default_zone_id to a zone.id, but I would imagine a better system of doing this exists. Thanks, Angelo, a desperate man -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Validates uniqueness scope
In a Rails 2.x validation to check if the name of some model is unique within a some category, I would use: `validates_uniqueness_of :name, :scope => :category_id` In Rails 3, this is replaced with: `validates :name, :uniqueness => true` However, I can't seem to find a method of defining the uniqueness' scope. Am I missing something? Thanks, Angelo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] what is the correct path for text_field in my view?
Hail Caesars! I have the following text entry field in my view: <%= text_field :order, :company_name %> However, company_name doesn't really reside in the orders table. It resides in the "company" table, which belongs to order, as follows: Order.company.company_name. This is where my controller method correctly saves it to. I added the company_name field to my orders table as a temporary measure so I wouldn't get a method not found error. Companies belong to orders and each order has one company. How can I change ":company_name" in my text_field helper to correctly reflect the correct relationship between Orders and companies (that is, Order.company.company_name instead of order[company_name] )? Companies belonging to orders, rather than orders belonging to companies, is correct for the business logic of this application. Thanks in advance for your help. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Rails + Mysql
I'm having the same "uninitialized constant MysqlCompat::MysqlRes" problem. Here is my configuration: OS X 10.6.2 Rails 2.3.5 5.5.0-m2 MySQL Community Server ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10.2.0] -Rahil On Mar 19, 9:39 pm, Yudi Soesanto wrote: > Jose, > > Uninstall gem mysql first (*sudo gem uninstall mysql*) and then install it > again with this command: > > $ sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config > > *for reference:* > Check on this linkhttp://wiki.rubyonrails.org/database-support/mysql, maybe > it can help. > > If it still doesn't work, try to reinstall mysql server. > > Good luck, > > Yudi Soesanto > > 2010/3/20 José Luis Romero > > > *mysql --version > > mysql Ver 14.14 Distrib 5.1.44, for redhat-linux-gnu (i386) using > > readline 5.1 > > > *rails -v > > Rails 2.3.5 > > > On Mar 19, 4:19 am, Yudi Soesanto wrote: > > > Jose, > > > > What rails version and mysql version are you using? > > > Do this: > > > *rails -v* > > > *mysql --version* > > > > I have the same issue as your after I upgraded to rails 2.2.2 and > > finally, I > > > got it work > > > What I did, I reinstall mysql and it worked ok now. > > > > Yudi Soesanto > > > > 2010/3/18 José Luis Romero > > > > > On Mar 18, 12:36 am, Conrad Taylor wrote: > > > > > José, can you verify that MySQL is running by doing the following: > > > > > > $ mysql -u > > > > > Yes it's running... > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Ruby on Rails: Talk" group. > > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > > . > > > > To unsubscribe from this group, send email to > > > > rubyonrails-talk+unsubscr...@googlegroups.com > > > > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Query Help
On 20 March 2010 09:57, Newb Newb wrote: > HEllo all, > > Kindly look into the below query > > @access_senders = GroupUser.find_by_sql "select distinct user_id from > group_users where group_id in (SELECT group_id FROM group_users where > user_id=2)" > > when i inspect the @access_senders i get the below > > [#, #, # 3518>, > #, #, # user_id: 352 > 1>, #, #] > > now i want to append 3 into the above result set...# 3> Can you provide the model relationships (has_many and so on) and what you are trying to achieve in words rather than sql? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: How to initially hide a drop-down control and have an image control make it visible
On 21 March 2010 05:02, RichardOnRails wrote: > OK, I got rid of all the syntax errors. > The vendor_drop list is now hidden on startup of the view > I switched from an image to a button > However, the drop list does not get displayed when the ShowList button > is clicked > Code is below. Ideas are most welcome > > > <%= button_to_function("ShowList", > % ) %> Have you checked the html generated by the above to make sure it is generating what you expect? Colin > > > <%= select_tag "test", > options_for_select(@current_vendors.collect { |v| > v.nickname }), > {:multiple => true} %> > > > > On Mar 21, 12:37 am, RichardOnRails > wrote: >> I think I improved two things in the version of lines 20-26 below: >> 1. I gave the div an id rather than a name >> 2. I gave the div a style of "display:none" so that it's hidden at >> every startup of the view >> >> <%# = image_tag "DownArrow.jpg" options = >> { onclick=page["vendor_droplist"].show } %> >> >> >> <%= select_tag "test", >> options_for_select(@current_vendors.collect { |v| >> v.nickname }), >> {:multiple => true} %> >> >> >> On Mar 21, 12:07 am, RichardOnRails >> >> wrote: >> > Hi, >> >> > I've got the following code in my attempt to provide the subject >> > functionality, lines 20-29 in view: >> >> > <%= image_tag "DownArrow.jpg" options = >> > { onclick=page["vendor_droplist"].show } %> >> > >> > >> > <%= select_tag "test", >> > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> > >> >> > Until I put in the options on image tag and added the div, this code >> > display a list of vendor nicknames. Now I have several problems: >> >> > 1. Syntax error in line 20 where an identifier was encountered where a >> > right-paren was expected (see below) >> > 2. I don't know how to make the vendor_droplist initially hidden >> >> > I've Googled for "Rails Ajax toggled item" and got a number of hits >> > but no apparent answer. I'll keep poking around the Web, but I >> > appreciate some suggestion(s). >> >> > Thanks in advance, >> > Richard >> >> > Showing app/views/expenses/new.html.erb where line #20 raised: >> >> > compile error >> > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ >> > new.html.erb:20: syntax error, unexpected tIDENTIFIER, expecting ')' >> > @output_buffer.concat " "; @output_buffer.concat(( image_tag >> > "DownArrow.jpg" options = >> > { onclick=page["vendor_droplist"].show } ).to_s); >> > @output_buffer.concat "\n" >> >> > ^ >> > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ >> > new.html.erb:20: odd number list for Hash >> > @output_buffer.concat " "; @output_buffer.concat(( image_tag >> > "DownArrow.jpg" options = >> > { onclick=page["vendor_droplist"].show } ).to_s); >> > @output_buffer.concat "\n" >> >> > ^ >> >> > Extracted source (around line #20): >> >> > 17: >> > 18: <%= f.label :vendor %> >> > 19: <%= f.text_field :vendor %> >> > 20: <%= image_tag "DownArrow.jpg" options = >> > { onclick=page["vendor_droplist"].show } %> >> > 21: >> > 22: >> > 23: <%= select_tag "test", >> >> > Trace of template inclusion: app/views/expenses/new.html.erb >> >> > RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS >> > Application Trace | Framework Trace | Full Trace >> >> > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ >> > new.html.erb:59:in `compile!' >> > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ >> > expenses_controller.rb:30:in `new' > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] How to initially hide a drop-down control and have an image control make it visible
On 21 March 2010 04:07, RichardOnRails wrote: > Hi, > > I've got the following code in my attempt to provide the subject > functionality, lines 20-29 in view: > > <%= image_tag "DownArrow.jpg" options = > { onclick=page["vendor_droplist"].show } %> I don't know whether it is still relevant after your later emails but the problem here is (at least in part) that you are missing a comma after "DownArrow.jpg" and a > after options = Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: MySQL Installation Issues
On 21 March 2010 00:48, Mike Montagne wrote: > Abraham Tio wrote: >>> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 >>> gem install mysql -- >>> --with-mysql-config=/usr/local/mysql/bin/mysql_config >>> Greg Donald >>> http://destiney.com/ >> >> YUP. this works. > > newbie question... > > I was able to get an error free install on OSX Leopard 10.6.2 with the > following. The first cds to the mysql gem location of my Leopard install > (may differ for others): > > cd /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 > sudo gem install mysql --no-rdoc --no-ri -- > --with-mysql-config=/usr/local/mysql/bin/mysql_config > > There were many "No definition for..." RDoc and Ri errors otherwise. > > Just starting my first Ruby project... and not so comfortable with this > install of the mysql gem. I expect there's possibly serious > ramifications of excluding these two processes. Can anybody tell us what > are we missing by resorting to these install parameters; and/or how can > we install with ri and rdoc successfully? ri and rdoc are just for documentation of the gem. Google them to find details. Not having them will not affect the operation of the gem. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Redirect_to that doesn't
I have some code that works when logged_in but not when not logged_in. The switch_theme action just changes the variable controlling the CSS stylesheet and does a 'redirect_to :back'. But no other action is called. The log looks like below. Ring any bells? TIA, Jeffrey Non-working: Processing ApplicationController#switch_theme (for 127.0.0.1 at 2010-03-21 03:20:53) [GET] Parameters: {"action"=>"switch_theme", "controller"=>"application"} User Columns (1.6ms) SHOW FIELDS FROM `users` User Load (0.6ms) SELECT * FROM `users` WHERE (`users`.`login` = 'Jeff') LIMIT 1 Redirected to http://127.0.0.1:3000/items Completed in 31ms (DB: 17) | 302 Found [http://127.0.0.1/switch_theme] == Working: Processing ApplicationController#switch_theme (for 127.0.0.1 at 2010-03-21 03:31:17) [GET] Parameters: {"action"=>"switch_theme", "controller"=>"application"} User Columns (1.8ms) SHOW FIELDS FROM `users` User Load (0.6ms) SELECT * FROM `users` WHERE (`users`.`login` = 'Jeff') LIMIT 1 User Load (0.5ms) SELECT * FROM `users` WHERE (`users`.`id` = '1') LIMIT 1 SQL (0.1ms) BEGIN User Update (0.5ms) UPDATE `users` SET `updated_at` = '2010-03-21 08:31:17', `perishable_token` = 'PE2oMoDx2BDp58azOFPx', `last_request_at` = '2010-03-21 08:31:17' WHERE `id` = 1 SQL (10195.9ms) COMMIT SQL (0.3ms) BEGIN User Update (0.7ms) UPDATE `users` SET `updated_at` = '2010-03-21 08:31:27', `perishable_token` = '9gNKIRTV7FdKYa-To9XQ', `theme` = 1 WHERE `id` = 1 SQL (829.0ms) COMMIT Redirected to http://127.0.0.1:3000/articles Completed in 11108ms (DB: 11042) | 302 Found [http://127.0.0.1/switch_theme] SQL (5.9ms) SET NAMES 'utf8' SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 Processing ArticlesController#index (for 127.0.0.1 at 2010-03-21 03:31:28) [GET] Parameters: {"action"=>"index", "controller"=>"articles"} User Columns (1.7ms) SHOW FIELDS FROM `users` User Load (0.5ms) SELECT * FROM `users` WHERE (`users`.`login` = 'Jeff') LIMIT 1 User Load (0.5ms) SELECT * FROM `users` WHERE (`users`.`id` = '1') LIMIT 1 SQL (0.3ms) BEGIN User Update (0.4ms) UPDATE `users` SET `updated_at` = '2010-03-21 08:31:28', `perishable_token` = 'QFCwPhX4OCZ4EmLj7Q6f', `last_request_at` = '2010-03-21 08:31:28' WHERE `id` = 1 SQL (52.3ms) COMMIT Feed Load (0.8ms) . -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Disabled Text_Field Value Not Saved
On 20 March 2010 18:52, Joshua Martin wrote: > The text_field should be disabled so that the user can't put it a > random date without regard to the terms or invoice date. So what stops them writing their own form and posting whatever value they want? Or using some DOM manipulation tools (Firebug?) to tweak the value? If you are calculating the value of the field client-side using JS, you shouldn't *trust* the returned params value server-side. It would be trivial to re-do in the controller whatever calculation you're doing on the client to guarantee the saved value is correct. This would then allow you to do anything you like with the JS client-side; update a text box as you are, or the contents of a span; don't stress about whether the textbox is read-only (because you're not using its return value), and worry less about whether the user's browser has JS support at all... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: How to create an index page with data from other contollers
Hiya Graham, It depends on your setup really but I would say in this case you would want another controller. If you've put all the shared html into partials then on the new index page you would just need to do a few <%= render :partial => 'PARTIAL_NAME'%> to pull in the html you need. http://api.rubyonrails.org/classes/ActionView/Partials.html http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials Cheers Luke -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Query Help
You could union it in the sql or do this in ruby: @access_senders << GroupUser.new(:user_id => 3) Cheers Luke -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Preparing an Asynchronous Response with ActionController
Tom Shealy wrote: > Hello, > > I was wondering if there's an easy way to make ActionController render a > response in an asynchronous background process. > > I have a large object graph which takes over a minute to serialize in > amf: > > render :amf => myData > > I'd like to render() the amf serialization in a workling process and > store the results in memcache key'd by original msg-id so the client can > get the serialized result in a subsequent request. > > Is there a simple way to perform the render() operation outside the > context of the controller? Something like: > > MyController.new.render({:amf=>myData}) > > (of course, render() is a protected method, so I can't do that. And I'm > also not sure where to obtain the serialized result since render() is > void). > > > Thanks, > > Tom For something that takes that long your best bet is to pass it off to like Backgroundrb (http://backgroundrb.rubyforge.org/) or delayed_job (http://github.com/tobi/delayed_job) for processing. I'm pretty sure you could call erb directly if you can't do it through the controller (and it's the actual render that takes the time): http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/ Cheers Luke -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.