[Rails] attr_accessor as boolean
Hi I have in my user model attr_accessor :no_password_validation_needed with_options :unless => :no_password_validation_needed do |p| p.validates_length_of :password, :minimum => 6 p.validates_confirmation_of :password end And from controller I do @user.no_password_validation_needed = false @user.update_attributes(params[:user]) And it works perfectly and now validation happens. If it is @user.no_password_validation_needed = true Then also I get the expected result as now validation not happens But now when @user.no_password_validation_needed = 2 #or any other value Now I get unexpected result as validation not happens That is same result when true? Why this?What modification should I make?Please help Thanks in advance 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] add contacts in those excel file to contact list
hi i wanted to upload a file using file uploader. alsoi wanted to add those contacts in those excel file to contact list how i can do this in rails.pls help -- 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 beta plugins
On Tue, Mar 23, 2010 at 6:50 PM, Ken Foust wrote: > Has anyone actually installed a plugin? > I have used > rails plugin install git://github.com/binarylogic/authlogic.git > I reacts too fast - doesn't complain but you can't find the plugin > anywhere. > > I have seen people giving advice on rails 3 to use script/plugin > obviously they are > responding having not even used the new release. > > If I am fighting a losing battle ok - I can work on other things with > rails 3. I also have read where people say the have authlogic working > but can't verify any of them. > > I knew it would be a tussle getting this all to work smoothly but it is > starting to give me a case of the red ass > > please any help will be appreciated but please don't guess just real > experience ! > Ken, you need to add the following to your Gemfile: gem "authlogic", :git => "git://github.com/binarylogic/authlogic.git" Then you'll invoke the following command: $ bundle install Good luck, -Conrad > -- > 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: Avoid web-service delay on an action
Thank you! On Wed, Mar 17, 2010 at 1:39 PM, Robert Walker wrote: > Robert Walker wrote: > > Sound like an excellent use case for delay_job (or similar) to me. > > Oops. I meant up type delayed_job... > -- > 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.
[Rails] files in lib directory not loading
Hi there I'm trying to install this rack application: http://fuelyourcoding.com/set-rails-logging-on-fire/ However, my rails3 setup is not picking up my lib file: app/lib/rack/firebug_logger.rb which contains: module Rack class FirebugLogger ... end end And in my config/environments/development.rb : App::Application.configure do ... config.middleware.use Rack::FirebugLogger end But rails3 is not finding my lib file :( uninitialized constant Rack::FirebugLogger (NameError) Any clues? thanks! -- 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] virtual/dynamic tables?
Hi, I'm trying to figure out a way for my users to create their own forms and store the data collected into their own customized table. For an example (though unlikely), say they want to create their own variant of an address book. They specify the fields, some field requirements (unique, size limit), perhaps a regex expression (possibly from a list of examples) to validate the data, then I create the forms for creation/update and the views for browsing, searching, deleting. Is there a plugin or example out there that can help with something like this? For dynamic creation of the storage, I was thinking of an architecture like so: 1. VirtualTable: * name:string * user_id:integer 2. DataColumn: * virtual_table_id:integer * name:string * data_type:string * limit:integer * regex_validator:string * unique:boolean 3. DataRow * virtual_table_id:integer * created_at:datetime * updated_at:datetime 4. DataString * data_column_id:integer * data_row_id:integer * data_value:string 5. DataText * data_column_id:integer * data_row_id:integer * data_value:text I'm guessing I'd have to put most of the CRUD logic in a single model, perhaps called VirtualData. Hopefully, the controller can just do something like VirtualData.create params, and the magic happens inside the model. I haven't worked out the details there yet. Is there a better way? -- 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 beta plugins
Has anyone actually installed a plugin? I have used rails plugin install git://github.com/binarylogic/authlogic.git I reacts too fast - doesn't complain but you can't find the plugin anywhere. I have seen people giving advice on rails 3 to use script/plugin obviously they are responding having not even used the new release. If I am fighting a losing battle ok - I can work on other things with rails 3. I also have read where people say the have authlogic working but can't verify any of them. I knew it would be a tussle getting this all to work smoothly but it is starting to give me a case of the red ass please any help will be appreciated but please don't guess just real experience ! -- 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] form_for with nested shallow route
Let's say I have: map.resources :teams do |team| team.resources :squads, :shallow => true end When I want to generate a form_for a squad, I need both the team and squad for new/create, but only the squad for edit. This means I need: edit: form_for(squad) new: form_for([team, squad]) This seems not very dry. Is there a more idiomatic way of doing this? Right now, I've abbreviated to: form_for(team = team ? [team, squad] : squad) (the team=team assignment makes sure there is no error if team is not defined) -- 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 to parse a User uploaded file, but don't care if it's saved
@Luke: Thanks! Yeah, I saw that tutorial, too. But, also like you said, it still saves it to a model, so I'd rather just let paperclip handle all that. Thank you anyway though. @Jeff: Thank you! For full disclosure, I'm still a little bit of a noob to Rails (and ruby) but I think I get more than the gist of your code. So, definitely a big thanks. I do have a couple questions as to what's going on though. Like I get that the file is read, along with its contents, but where is it read from? Like, is the file actually uploaded to a temp directory, and you're saying that I just don't have to expressly mess with that directory? Or, is it just held in memory in a Rails process somewhere? Might that be worse than just storing the file, then deleting it later? I'm just asking, I honestly don't know. Also, while the file uploads, a Rails process is not tied up, correct? It's actually being buffered by the server? A big thank you Jeff, and to anyone else that wants to chime in. I think this is definitely a huge start down the right path. On Mar 23, 11:35 am, Jeff Lewis wrote: > One way would be to just process the uploaded-file data from the > request as needed and not worry about saving or doing anything else > with the tmp-saved uploaded-file itself, something like: > > ### in ./app/models/uploadable_file.rb > class UploadableFile > > ### for use in testing: > > def initialize(fname, contents) > @fname = fname > @contents = contents > end > > def original_filename > return @fname > end > > def read > return @contents > end > > ### class meths: > > def self.parse(upfile) > return nil if upfile.blank? or not (upfile.respond_to? > ('original_filename')\ > and upfile.respond_to?('read')) > > orig_fname = upfile.original_filename > contents = upfile.read > # parse/process contents > end > end > > Then just call that class meth in your controller to parse the > uploaded file for an example file form element of name "upfile": > > ### in some controller meth that handles that multipart/form-data > form: > ... > parsed_contents = UploadableFile.parse(params[:upfile]) > # check results > > Jeff > > On Mar 22, 9:37 pm, GoodGets wrote: > > > > > parsing the file's not the problem, just not sure what to do with it > > before or after. I was thinking about uploading the files using > > Paperclip, parsing it, then deleting itfrom the database. But, that > > all seems a little unnecessary, especially if I don't care if they are > > even saved. > > > I then thought about grabbing them from the temp directory, but > > honestly wasn't sure how to go about doing that. So before I really > > delve into the Tempfile, should I even worry about it in the first > > place? Each user uploaded file will be like 30kb max, and I'll only > > be processing a couple hundred a month. Also, I'm hosted on heroku, > > so the s3 transfers (if I do save the file) will be free. What ya > > think? > > > Any advice really is 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: Rails 3: Update responding with empty json
No ideas? On Mar 22, 7:42 pm, Fabio Kreusch wrote: > This is it (HAML): > > #category-form > - form_for @category, :remote => true do |f| > %fieldset > %legend= t('activerecord.models.category') > %p > = f.label :name > %br > = f.text_field :name > %p > %button{:type => 'submit', :class => 'positive'}= > t('dashboard.save') > > The same form is used both for create and update. I use this Jquery > code to change between create and update actions (this is called on > click of the 'new category' button', or on the on click of an existing > category: > > attr = $(this).data('attributes'); > form = categoryForm.find('form'); > form.find('input[name=_method]').remove(); > > if(attr.id) { > action = '/categories/'+attr.id; > form.append($('', {type: 'hidden', name: '_method', value: > 'put'})); > } else { > action = '/expense_categories'; > } > > $.each(attr, function(i, val){ > categoryForm.find('[id$='+i+']').val(val); > }); > > form.attr('action', action); > > On Mar 22, 2:05 am, Conrad Taylor wrote: > > > > > 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> > > > > e...@googlegroups.com> > > > > > > > . > > > > > > > For more options, visit this group at > > > > > > >htt
[Rails] Re: redirection in format.json ...
in my controller the create action is : respond_to do |format| if @request.save flash[:notice] = 'Request was successfully created.' format.html { redirect_to requests_url } format.xml { render :xml => @request, :status => :created, :location => @request } format.json { render :json => {:result => 'success', :redirect => requests_url } } format.js else . once the request is saved, ... I get in the log Completed in 563ms (View: 1, DB: 5) | 200 OK [http://localhost/requests] I should have 200 OK [http://localhost:3000/requests] -- 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] How to move ruby from /usr/bin/ to /usr/local/bin/ on OSX Snow leopard 10.6
On Tue, Mar 23, 2010 at 1:25 PM, Peter wrote: > Hi i'm a beginner to ruby on rails and I am trying to start a tutorial > but having trouble making sure ruby is in the right place. When i use > the terminal and ask "which ruby" it comes back with /usr/bin/ whilst > I think i needs it to be in usr/local/bin but i don't know how to get > it there. There is not even a bin folder in the local area at present. > I am following these up to date installation instructions > > http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard > but still can't get it in the local folder. ANy help would be very > grateful. > > Regards Peter > > Peter, if you're talking about moving the system installed Ruby, I would recommend against this action because this is installed by the OS. Also, you do not know what service(s) depends on it. However, I would recommend using Ruby Version Manager (RVM) to manage your Ruby installations. Thus, you can find more information about RVM here: http://rvm.beginrescueend.com Good luck, -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 > . > 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: redirection in format.json ...
Lasse Bunk wrote: > Here is an example: > > format.json { render :json => { :redirect => requests_url } } > > and then on your client redirect like this: > > if (json.redirect) { > window.location = json.redirect; > } > > Also try http://www.google.com/search?q=json+redirect > > Does this solve your problem? > > /Lasse > > 2010/3/23 Erwin thanks for your help it seems that json.redirect is bypassed... I put an alert, and it's not fired up if (json.redirect) { alert('redirect'); } -- 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] How to move ruby from /usr/bin/ to /usr/local/bin/ on OSX Snow leopard 10.6
Hi i'm a beginner to ruby on rails and I am trying to start a tutorial but having trouble making sure ruby is in the right place. When i use the terminal and ask "which ruby" it comes back with /usr/bin/ whilst I think i needs it to be in usr/local/bin but i don't know how to get it there. There is not even a bin folder in the local area at present. I am following these up to date installation instructions http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard but still can't get it in the local folder. ANy help would be very grateful. Regards Peter -- 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] has_many_polymorphs with searchlogic
Has anyone been able to use searchlogic with has_many_polymorphs? Are they compatible? -- 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] redirection in format.json ...
Here is an example: format.json { render :json => { :redirect => requests_url } } and then on your client redirect like this: if (json.redirect) { window.location = json.redirect; } Also try http://www.google.com/search?q=json+redirect Does this solve your problem? /Lasse 2010/3/23 Erwin > I have presently a render :json which modify the current page > > if @request.save > format.html { redirect_to(@request) } >format.json { render :json => { :result => 'success', :request > => request_path(@request) } } > > > but I would like rather to redirect to an index page > I wrote this but it doesn't redirect ... > >format.json { redirect_to requests_url } > > what should I write to redirect correctly to an html page ? > > thanks for your help > > erwin > > -- > 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: Simple Backup???
Thanks Andy and ayupmeduck... Yes, this was the issue (Sorry, I'm mostly a LAMP guy, this was probably pretty obvious to Rails developers)... In our clean scripts we were running a command to create a new Rails project before we restored. I got rid of this and started with a clean folder and everything works great now. Thanks again! On Mar 23, 1:08 am, Andy Jeffries wrote: > On 20 March 2010 00:33, 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! > > If you see that message, then you still have a public/index.html file which > should have been gone a long time ago! > > Delete that (or rename it) and then see what error you get. > > Cheers, > > Andy -- 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] Upcoming app > Research and Prep
Hey everyone. I'm a one person team and in the next month need to produce and deploy an application. I've been playing with rails for a little over a year now and recently deployed my first app as a private contract. I'm now planning development on a start up company. The app should be expecting high volumes (not like Twitter but high for sure. Its no social media app) My target audience is very specific but in certain locals the app has been requested by many users who are in fact waiting for the app to deploy. Smaller Volumes actually uploading files and adding objects to the db. Many people surfing the site. (Probably the same sort of RATIOS as cragslist (posters:readers, but not near the volume.) My current plan is and I need some help with this: Start on shared hosting unlimited traffic/storage. Will move to dedicated-virtual if shared hosting causes performance issues when traffic picks up. Behavior Drive Development via RSpec & Cucumber. Build the App in rails with ActiveRecord (I read somewhere ActiveRecord can be swapped out for something faster, Should I use something else?) Use multiple MySQL databases 1 master for writing, at *least* 2 slaves for reading. (Any info on this would be good.) Run multiple mongrel instances via mongrel_cluster. (How many is sufficient? I think currently I have 4 available on my hosting, can upgrade later if needed. So that would be 1 main instance and 3 extras.) Paypal via Active_Merchant for all payment processing. (May accept money order and check but that's not app related.) Amazon S3 services for file/image upload & hosting (Via paperclip.) I may start by hosting all images from local server as I have unlimited space but I feel as the app grows my hosting may not appreciate the traffic and I'll move to Amazon S3. Deploy via Git & Capistrano I'm going to do all the base functionality for the application myself. Get it running get people signed up get them using the app. Hopefully the multiple db's and mongrel instances should supply enough speed to start. At which point if everything goes as planned (it never does) I'll outsource and get added security. Get queries optimized and work on overall performance via back end processes etc that will be over my head for sure hence the outsource or hire of private team. I know at this point it will be necessary to do these things and costs for such have been accounted for. Any help with gathering resources where I can find more information about the above topics or personal experiences 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.
Re: [Rails] Sorting forum topics by the most recent replies
On 3/23/2010 2:56 PM, DanC wrote: I have built a simple forum but am having difficult getting the topics to display in the order of their latest reply. The associations are as follows: class Forum< ActiveRecord::Base has_many :topics, :order => "sticky DESC, created_at DESC" has_many :replies, :through => :topics class Topic< ActiveRecord::Base belongs_to :forum has_many :replies, :order => "created_at", :dependent => :destroy class Reply< ActiveRecord::Base belongs_to :topic And in my controller I am calling @topics = @forum.topics What I would like to do is sort the topics by the created_at of their most recent posts. Any advice appreciated. Add a last_reply_at field to Topic. Add a after_save to Reply that updates last_reply_at. When you find all topics sort by last_reply_at. Thanks, Dan -- Jack Christensen ja...@hylesanderson.edu -- 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] :has_many and :controller specified in routes.rb
Maybe you could use: map.resources :buckets, :controller => 'v1/buckets' do |buckets| buckets.resources :apples, :controller => 'v1/apples' end I know this is a bit more code than just using :has_many, but I don't think :has_many lets you specify a different controller. /Lasse 2010/3/23 gsw > Have an app using older version of Rails (2.3.2) that I need some > routing assistance with if anyone has a minute. > > The app was originally designed to be purely html view, and an xml and > json api was hacked on. To keep it clean, we are now moving the first > version of the api (v1) under its own directory (v1) under app/ > controllers but still responding to the old paths. > > One of the parts of the new routes.rb specifies: > map.resources :buckets, :has_many => :apples, :controller => 'v1/ > buckets' > > However, when I do rake routes, this produces: > ... > buckets GET /buckets(.:format) {:controller=>"v1/ > buckets", :action=>"index"} > POST /buckets(.:format) {:controller=>"v1/ > buckets", :action=>"create"} > new_bucketGET /buckets/new(.:format) {:controller=>"v1/ > buckets", :action=>"new"} > edit_bucket GET /buckets/:id/edit(.:format) {:controller=>"v1/ > buckets", :action=>"edit"} > bucketGET /buckets/:id(.:format) {:controller=>"v1/ > buckets", :action=>"show"} > PUT /buckets/:id(.:format) {:controller=>"v1/ > buckets", :action=>"update"} > DELETE /buckets/:id(.:format) {:controller=>"v1/ > buckets", :action=>"destroy"} > bucket_apples GET /buckets/:bucket_id/apples(.:format) > {:controller=>"apples", :action=>"index"} > POST /buckets/:bucket_id/apples(.:format) > {:controller=>"apples", :action=>"create"} > new_bucket_apple GET /buckets/:bucket_id/apples/new(.:format) > {:controller=>"apples", :action=>"new"} > edit_bucket_apple GET /buckets/:bucket_id/apples/:id/edit(.:format) > {:controller=>"apples", :action=>"edit"} > bucket_apple GET /buckets/:bucket_id/apples/:id(.:format) > {:controller=>"apples", :action=>"show"} > PUT /buckets/:bucket_id/apples/:id(.:format) > {:controller=>"apples", :action=>"update"} > DELETE /buckets/:bucket_id/apples/:id(.:format) > {:controller=>"apples", :action=>"destroy"} > ... > (sorry for the bad formatting) > > Notice that the routes for the actions specific to the model > referenced by :has_many ignores the specification of the controller > (they go to :controller=>"apples" instead of :controller=>"v1/ > apples"). > > Sorry for the n00b routing question. I didn't find such an example of > how to set the controller of the :has_many referenced model yet, but > maybe it is an option somewhere, or I could setup another route for > that? > > -- > 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: NoMethodError in AdminController#index
On 23 March 2010 20:14, dwhitekiss wrote: > I still get the same errors when I did option 1 The error you had before was, from your first post, NoMethodError in AdminController#index undefined method `scaffold' for AdminController:Class Are you saying you still get that error, and with the trace below? Colin > > /home/darwin/Sites/music_library/vendor/plugins/scaffolding/lib/ > scaffolding.rb:107:in `list' > /home/darwin/Sites/music_library/vendor/plugins/scaffolding/lib/ > scaffolding.rb:95:in `index' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > base.rb:1331:in `send' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > base.rb:1331:in `perform_action_without_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > filters.rb:617:in `call_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > filters.rb:610:in `perform_action_without_benchmark' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > benchmarking.rb:68:in `perform_action_without_rescue' > /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ > core_ext/benchmark.rb:17:in `ms' > /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' > /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ > core_ext/benchmark.rb:17:in `ms' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > benchmarking.rb:68:in `perform_action_without_rescue' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > rescue.rb:160:in `perform_action_without_flash' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > flash.rb:146:in `perform_action' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > base.rb:532:in `send' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > base.rb:532:in `process_without_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > filters.rb:606:in `process' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > base.rb:391:in `process' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > base.rb:386:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > routing/route_set.rb:437:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > dispatcher.rb:87:in `dispatch' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > dispatcher.rb:121:in `_call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > dispatcher.rb:130:in `build_middleware_stack' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ > query_cache.rb:29:in `call' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ > query_cache.rb:29:in `call' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ > connection_adapters/abstract/query_cache.rb:34:in `cache' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ > query_cache.rb:9:in `cache' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ > query_cache.rb:28:in `call' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ > connection_adapters/abstract/connection_pool.rb:361:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > string_coercion.rb:25:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb: > 24:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > params_parser.rb:15:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > session/cookie_store.rb:93:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > failsafe.rb:26:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in > `synchronize' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > dispatcher.rb:114:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > reloader.rb:34:in `run' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > dispatcher.rb:108:in `call' > /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in > `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call' > /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb: > 17:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb: > 13:in `call' > /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb: > 50:in `service' > /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' > /usr/lib/ruby/1.
Re: [Rails] Re: Blank Log Files - New to RoR - Ubuntu Server 9.10
On Tue, 2010-03-23 at 12:38 -0700, Justin wrote: > Michael, > > Thanks SO much for helping me. I still haven't gotten the logs to > populate, even with root:www-data > > No luck with your chown -R root:www-data testapp1 > If restarted apache: /etc/init.d/apache2 restart > * Restarting web server apache2 > ... waiting...done. > > My symbolic link: > $ cd /var/www > $ ls -l > lrwxrwxrwx 1 root www-data 31 2010-03-21 07:55 testapp1 -> /home/ > justinschier/www/testapp1 > > My home www folder: > $ cd /home/justinschier > $ ls -l > drwxrwxrwx 3 root www-data 4096 2010-03-20 08:02 www > > My testapp1 folder: > $ cd /home/justinschier/www > $ ls -l > drwxrwxrwx 13 root www-data 4096 2010-03-20 08:02 testapp1 > > My log folder: > $ cd /home/justinschier/www/testapp1 > $ ls -l > ... > drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 log > ... (everything's the same permissions and ownership as log) > > My log files: > -rwxrwxrwx 1 root www-data 1676 2010-03-22 20:58 development.log > -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 production.log > -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 server.log > -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 test.log > > I know the development.log is showing now, BUT that's because I tried > running WebBrick. That's why there's something in there. > > > My /public folder (no .htaccess file): > $ cd /home/justinschier/www/testapp1/public > $ ls -al > drwxrwxrwx 5 root www-data 4096 2010-03-22 08:21 . > drwxrwxrwx 13 root www-data 4096 2010-03-20 08:02 .. > -rwxrwxrwx 1 root www-data 947 2010-03-20 08:02 404.html > -rwxrwxrwx 1 root www-data 930 2010-03-20 08:02 422.html > -rwxrwxrwx 1 root www-data 948 2010-03-20 08:02 500.html > -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 favicon.ico > drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 images > -rwxrwxrwx 1 root www-data 7466 2010-03-20 08:02 index.html > drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 javascripts > -rwxrwxrwx 1 root www-data 204 2010-03-20 08:02 robots.txt > drwxrwxrwx 3 root www-data 4096 2010-03-22 15:30 stylesheets > > > Still when I run this, the log files don't grow at all: > http://testapp1.fuse.sonikserver.com/ > Welcome Aboard Page loads correctly > > http://testapp1.fuse.sonikserver.com/rails/info/properties > and I still get "We're sorry, but something went wrong" > > Apache has instances running as both root and www-data: > $ ps aux | grep apache2 > root 14157 0.0 0.3 141016 8040 ?Ss 12:24 0:00 /usr/ > sbin/apache2 -k start > root 14170 0.0 0.0 23192 1888 ?Sl 12:24 0:00 /var/ > lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/ > ApplicationPoolServerExecutable 0 /var/lib/gems/1.8/gems/ > passenger-2.2.11/bin/passenger-spawn-server /usr/bin/ruby1.8 /tmp/ > passenger.14157 > www-data 14175 0.0 0.2 141492 6036 ?S12:24 0:00 /usr/ > sbin/apache2 -k start > www-data 14176 0.0 0.2 141348 5812 ?S12:24 0:00 /usr/ > sbin/apache2 -k start > www-data 14177 0.0 0.2 141348 5812 ?S12:24 0:00 /usr/ > sbin/apache2 -k start > www-data 14178 0.0 0.2 141476 5796 ?S12:24 0:00 /usr/ > sbin/apache2 -k start > www-data 14179 0.0 0.2 141476 5924 ?S12:24 0:00 /usr/ > sbin/apache2 -k start > www-data 14183 0.0 0.2 141476 5852 ?S12:24 0:00 /usr/ > sbin/apache2 -k start > www-data 14188 0.0 0.2 141016 4692 ?S12:25 0:00 /usr/ > sbin/apache2 -k start > root 14206 0.0 0.0 7340 884 pts/0S+ 12:27 0:00 grep > apache2 > > > I even got rid of the symbolic link (above) and no change: > > $ vi /etc/apache2/sites-available/default > > Now reads: > > ... default part ommitted for this post > > LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.11/ > ext/apache2/mod_passenger.so > PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.11 > PassengerRuby /usr/bin/ruby1.8 > > > ServerName testapp1.fuse.sonikserver.com > DocumentRoot /home/justinschier/www/testapp1/public > > Allow from all > Options -MultiViews > > > > Man, I am so out of ideas. Anything else you can think of for me to > try? > > Thanks again SOOO much. If you have an Amazon wish list, I'm totally > buying you something. log files are written by rails as the 'user', not by the apache user. See the directory listing of my 'logs' below. Apache user is www-user anyway, not root. Root user is only for the master process. you should change the ownership back on all files/folders in /home/justinscheier/www/testapp1 Then, you need to indicate in your apache configuration which RailsEnv is to be used... ServerName testapp1.fuse.sonikserver.com DocumentRoot /home/justinschier/www/testapp1/public ## note the following line ## RailsEnv production # or development if that's what you are running ## Allow from all Options -MultiViews Passenger is very clever
Re: [Rails] Fixtures and Associations
On 23 March 2010 18:05, David Ishmael wrote: > I have a concrete table with an associated join table and I'm trying to > load up some test data but cannot seem to get the fixtures file correct. > The parent/child relationship works great but the fixtures fail to load. > Any help would be greatly appreciated. > > Here is what I have... > > # app/models/node.rb > class Node < ActiveRecord::Base > belongs_to :category > belongs_to :status > > has_one :parents, Why is that not has_one :parent ? > :class_name => "NodeGroup", > :foreign_key => "child_id" > > has_one :parent, :through => :parents That would only work if there were a relationship to a parents table > > has_many :children, > :class_name => "NodeGroup", > :foreign_key => "parent_id" > > end > > # app/models/node_group.rb > class NodeGroup < ActiveRecord::Base > belongs_to :parent, :class_name => "Node" > belongs_to :child, :class_name => "Node" > end > > # test/fixtures/nodes.yml Should be node_groups.yml > parent1: > name: Parent1 > children: child1 I would have expected this to be parent: Parent1 child: child1 Colin > > parent2: > name: Parent2 > > child1: > name: Child1 > -- > 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.
[Rails] Re: NoMethodError in AdminController#index
I still get the same errors when I did option 1 /home/darwin/Sites/music_library/vendor/plugins/scaffolding/lib/ scaffolding.rb:107:in `list' /home/darwin/Sites/music_library/vendor/plugins/scaffolding/lib/ scaffolding.rb:95:in `index' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:1331:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:1331:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ filters.rb:617:in `call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ filters.rb:610:in `perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ core_ext/benchmark.rb:17:in `ms' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ core_ext/benchmark.rb:17:in `ms' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ rescue.rb:160:in `perform_action_without_flash' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ flash.rb:146:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:532:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:532:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ filters.rb:606:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:391:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:386:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ routing/route_set.rb:437:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:87:in `dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:121:in `_call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:130:in `build_middleware_stack' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ query_cache.rb:29:in `call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ query_cache.rb:29:in `call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/abstract/query_cache.rb:34:in `cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ query_cache.rb:9:in `cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ query_cache.rb:28:in `call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/abstract/connection_pool.rb:361:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ string_coercion.rb:25:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb: 24:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ params_parser.rb:15:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ session/cookie_store.rb:93:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ failsafe.rb:26:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:114:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ reloader.rb:34:in `run' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:108:in `call' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb: 17:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb: 13:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb: 50:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `sta
[Rails] Sorting forum topics by the most recent replies
I have built a simple forum but am having difficult getting the topics to display in the order of their latest reply. The associations are as follows: class Forum < ActiveRecord::Base has_many :topics, :order => "sticky DESC, created_at DESC" has_many :replies, :through => :topics class Topic < ActiveRecord::Base belongs_to :forum has_many :replies, :order => "created_at", :dependent => :destroy class Reply < ActiveRecord::Base belongs_to :topic And in my controller I am calling @topics = @forum.topics What I would like to do is sort the topics by the created_at of their most recent posts. Any advice appreciated. Thanks, Dan -- 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: Blank Log Files - New to RoR - Ubuntu Server 9.10
On 23 March 2010 19:38, Justin wrote: > Michael, > > Thanks SO much for helping me. I still haven't gotten the logs to > populate, even with root:www-data Justin, I don't know what you're so impressed with me for... we've not sorted your problem. And I'm afraid I pretty much out of ideas, I'm afraid :-( It's bugging me, because I had the *same* issue a couple of weeks ago (log files not being written to), although my application was working. But I can't remember what was the thing that fixed it, and I'm not at home to look to see if I made any notes. Just looking through your post again; if you delete the log files, do they get created by Apache? And what does the tail of the Apache log say? -- 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: Blank Log Files - New to RoR - Ubuntu Server 9.10
Michael, Thanks SO much for helping me. I still haven't gotten the logs to populate, even with root:www-data No luck with your chown -R root:www-data testapp1 If restarted apache: /etc/init.d/apache2 restart * Restarting web server apache2 ... waiting...done. My symbolic link: $ cd /var/www $ ls -l lrwxrwxrwx 1 root www-data 31 2010-03-21 07:55 testapp1 -> /home/ justinschier/www/testapp1 My home www folder: $ cd /home/justinschier $ ls -l drwxrwxrwx 3 root www-data 4096 2010-03-20 08:02 www My testapp1 folder: $ cd /home/justinschier/www $ ls -l drwxrwxrwx 13 root www-data 4096 2010-03-20 08:02 testapp1 My log folder: $ cd /home/justinschier/www/testapp1 $ ls -l ... drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 log ... (everything's the same permissions and ownership as log) My log files: -rwxrwxrwx 1 root www-data 1676 2010-03-22 20:58 development.log -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 production.log -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 server.log -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 test.log I know the development.log is showing now, BUT that's because I tried running WebBrick. That's why there's something in there. My /public folder (no .htaccess file): $ cd /home/justinschier/www/testapp1/public $ ls -al drwxrwxrwx 5 root www-data 4096 2010-03-22 08:21 . drwxrwxrwx 13 root www-data 4096 2010-03-20 08:02 .. -rwxrwxrwx 1 root www-data 947 2010-03-20 08:02 404.html -rwxrwxrwx 1 root www-data 930 2010-03-20 08:02 422.html -rwxrwxrwx 1 root www-data 948 2010-03-20 08:02 500.html -rwxrwxrwx 1 root www-data0 2010-03-20 08:02 favicon.ico drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 images -rwxrwxrwx 1 root www-data 7466 2010-03-20 08:02 index.html drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 javascripts -rwxrwxrwx 1 root www-data 204 2010-03-20 08:02 robots.txt drwxrwxrwx 3 root www-data 4096 2010-03-22 15:30 stylesheets Still when I run this, the log files don't grow at all: http://testapp1.fuse.sonikserver.com/ Welcome Aboard Page loads correctly http://testapp1.fuse.sonikserver.com/rails/info/properties and I still get "We're sorry, but something went wrong" Apache has instances running as both root and www-data: $ ps aux | grep apache2 root 14157 0.0 0.3 141016 8040 ?Ss 12:24 0:00 /usr/ sbin/apache2 -k start root 14170 0.0 0.0 23192 1888 ?Sl 12:24 0:00 /var/ lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/ ApplicationPoolServerExecutable 0 /var/lib/gems/1.8/gems/ passenger-2.2.11/bin/passenger-spawn-server /usr/bin/ruby1.8 /tmp/ passenger.14157 www-data 14175 0.0 0.2 141492 6036 ?S12:24 0:00 /usr/ sbin/apache2 -k start www-data 14176 0.0 0.2 141348 5812 ?S12:24 0:00 /usr/ sbin/apache2 -k start www-data 14177 0.0 0.2 141348 5812 ?S12:24 0:00 /usr/ sbin/apache2 -k start www-data 14178 0.0 0.2 141476 5796 ?S12:24 0:00 /usr/ sbin/apache2 -k start www-data 14179 0.0 0.2 141476 5924 ?S12:24 0:00 /usr/ sbin/apache2 -k start www-data 14183 0.0 0.2 141476 5852 ?S12:24 0:00 /usr/ sbin/apache2 -k start www-data 14188 0.0 0.2 141016 4692 ?S12:25 0:00 /usr/ sbin/apache2 -k start root 14206 0.0 0.0 7340 884 pts/0S+ 12:27 0:00 grep apache2 I even got rid of the symbolic link (above) and no change: $ vi /etc/apache2/sites-available/default Now reads: ... default part ommitted for this post LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.11/ ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.11 PassengerRuby /usr/bin/ruby1.8 ServerName testapp1.fuse.sonikserver.com DocumentRoot /home/justinschier/www/testapp1/public Allow from all Options -MultiViews Man, I am so out of ideas. Anything else you can think of for me to try? Thanks again SOOO much. If you have an Amazon wish list, I'm totally buying you something. Justin On Mar 23, 6:16 am, Michael Pavling wrote: > On 23 March 2010 09:57, Michael Pavling wrote: > > > On 22 March 2010 14:11,Justin wrote: > >> I didn't know about www-data, but your suggestion still didn't work. > > I just checked a server I have here (Ubuntu9.04LTS) and the directory > ownership is slightly different to what I said. > I've got it as: > chown -R root.www-data my_rails_app > > Also worth checking the permissions of the log folder, and if there's > log files in there, check their perms - delete them if necessary and > see if the app recreates them once all the ownership is set. -- 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?
Re: [Rails] Re: How do I set defaults for view parameters?
On Tue, Mar 23, 2010 at 12:43 PM, Colin Law wrote: > On 23 March 2010 16:31, Robin Ting wrote: >> I don't, but I figure there must be a way to just have it in the >> controllers. Oh well thanks, I'll start another thread. > > You don't what? It is best to insert your reply at the appropriate > point in the comment so that it is easier to follow the thread. If > you mean that you don't have the .:format in the route where you are > using some_url.csv then that is the problem. hmm yeah that's what I meant. Thanks I think I figured it out. This is the code I will use in the routes.rb file: map.admin 'admin.:format', :controller => 'user_sessions', :action => 'admin' > Colin > >> >> On Tue, Mar 23, 2010 at 12:17 PM, Colin Law wrote: >>> On 23 March 2010 16:03, Robin Ting wrote: Yeah thanks for the help! By the way do you know how I can get the "format.csv { render :csv => @logs }" part to work? I have tested it on an index page and that works, but when I try it on this admin page it says it doesn't understand the URL. I have set a direct path to the admin page instead of the standard "controller/action" path in the routes.rb file, but even if i go through the "controller/action" path it still says it can't find it. Is it because of that direct path in the routes.rb that it's giving me the error? >>> >>> Have you got the .:format bit in the route? Otherwise I would suggest >>> a new thread for this question as routing is not my high point. >>> >>> 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. >>> >>> >> >> -- >> 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. > > -- 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] redirection in format.json ...
I have presently a render :json which modify the current page if @request.save format.html { redirect_to(@request) } format.json { render :json => { :result => 'success', :request => request_path(@request) } } but I would like rather to redirect to an index page I wrote this but it doesn't redirect ... format.json { redirect_to requests_url } what should I write to redirect correctly to an html page ? thanks for your help erwin -- 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: submit form in popup and send value back to the main page
I added some javascript to the create.html.erb template that opens in the popup after the document form submits. The javascript is supposed to close the popup and send the title of the document back to the main page but it's not working. Anyone know why? this is what is in the create.html.erb template: function copyData(){ var docField = window.opener.document.getElementById('title'); docField.setValue('<%=h @doc.title %>'); this.close(); } copyData(); On Mar 23, 6:06 pm, ES wrote: > I made a popup within object1's form to show another form to create a > new document object to associate with object1. When I click the > submit button I want > 1) the document object to be created > 2) the popup to close > 3) the value in the document "title" field to get added to the > document name field in object1's form. > > I've made the form for the document object in the popup but I'm having > trouble figuring out the logic for 2) and 3). I'd imagine I have to > use javascript to close the popup and send the title back to the main > page. -- 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] Fixtures and Associations
I have a concrete table with an associated join table and I'm trying to load up some test data but cannot seem to get the fixtures file correct. The parent/child relationship works great but the fixtures fail to load. Any help would be greatly appreciated. Here is what I have... # app/models/node.rb class Node < ActiveRecord::Base belongs_to :category belongs_to :status has_one :parents, :class_name => "NodeGroup", :foreign_key => "child_id" has_one :parent, :through => :parents has_many :children, :class_name => "NodeGroup", :foreign_key => "parent_id" end # app/models/node_group.rb class NodeGroup < ActiveRecord::Base belongs_to :parent, :class_name => "Node" belongs_to :child, :class_name => "Node" end # test/fixtures/nodes.yml parent1: name: Parent1 children: child1 parent2: name: Parent2 child1: name: Child1 -- 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] :has_many and :controller specified in routes.rb
Have an app using older version of Rails (2.3.2) that I need some routing assistance with if anyone has a minute. The app was originally designed to be purely html view, and an xml and json api was hacked on. To keep it clean, we are now moving the first version of the api (v1) under its own directory (v1) under app/ controllers but still responding to the old paths. One of the parts of the new routes.rb specifies: map.resources :buckets, :has_many => :apples, :controller => 'v1/ buckets' However, when I do rake routes, this produces: ... buckets GET /buckets(.:format) {:controller=>"v1/ buckets", :action=>"index"} POST /buckets(.:format) {:controller=>"v1/ buckets", :action=>"create"} new_bucketGET /buckets/new(.:format) {:controller=>"v1/ buckets", :action=>"new"} edit_bucket GET /buckets/:id/edit(.:format) {:controller=>"v1/ buckets", :action=>"edit"} bucketGET /buckets/:id(.:format) {:controller=>"v1/ buckets", :action=>"show"} PUT /buckets/:id(.:format) {:controller=>"v1/ buckets", :action=>"update"} DELETE /buckets/:id(.:format) {:controller=>"v1/ buckets", :action=>"destroy"} bucket_apples GET /buckets/:bucket_id/apples(.:format) {:controller=>"apples", :action=>"index"} POST /buckets/:bucket_id/apples(.:format) {:controller=>"apples", :action=>"create"} new_bucket_apple GET /buckets/:bucket_id/apples/new(.:format) {:controller=>"apples", :action=>"new"} edit_bucket_apple GET /buckets/:bucket_id/apples/:id/edit(.:format) {:controller=>"apples", :action=>"edit"} bucket_apple GET /buckets/:bucket_id/apples/:id(.:format) {:controller=>"apples", :action=>"show"} PUT /buckets/:bucket_id/apples/:id(.:format) {:controller=>"apples", :action=>"update"} DELETE /buckets/:bucket_id/apples/:id(.:format) {:controller=>"apples", :action=>"destroy"} ... (sorry for the bad formatting) Notice that the routes for the actions specific to the model referenced by :has_many ignores the specification of the controller (they go to :controller=>"apples" instead of :controller=>"v1/ apples"). Sorry for the n00b routing question. I didn't find such an example of how to set the controller of the :has_many referenced model yet, but maybe it is an option somewhere, or I could setup another route for that? -- 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 + Different ORM
Well, ignore that. Rails does autoloading quite a bit differently that I expected and it appears my stuff is getting loaded. *grimace* On Mar 23, 10:13 am, cult hero wrote: > I'm migrating an old project (not Rails) over to Rails 3. I've been > using Sequel as my ORM and I'm quite happy with it. However, when I > add Sequel models to my app/model directory, they don't seem to load > on their own. Am I going to need to load them manually or do I need to > set some kind of configuration option somewhere? -- 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: Displaying a nested field as a label
That's exactly what I was looking for! THANK YOU! And thanks for the insight. -a On Mar 23, 12:10 pm, Michael Pavling wrote: > On 23 March 2010 17:01, andrew wrote: > > > A! a.class = formbuilder. I thought it was a Comments class. > > Now I know what to look up I guess my question after all is there > > any way to "extract" a data value from a field within a formbuilder? > > (if I got my terminology right) > > a.object.text > (although I'm using Formtastic "SemanticFormBuilder" objects here, so > have fingers crossed the method is the same - dumping "a.methods" > would help you a little if 'object' doesn't work...) -- 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 + Different ORM
I'm migrating an old project (not Rails) over to Rails 3. I've been using Sequel as my ORM and I'm quite happy with it. However, when I add Sequel models to my app/model directory, they don't seem to load on their own. Am I going to need to load them manually or do I need to set some kind of configuration option somewhere? -- 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: Displaying a nested field as a label
On 23 March 2010 17:01, andrew wrote: > A! a.class = formbuilder. I thought it was a Comments class. > Now I know what to look up I guess my question after all is there > any way to "extract" a data value from a field within a formbuilder? > (if I got my terminology right) a.object.text (although I'm using Formtastic "SemanticFormBuilder" objects here, so have fingers crossed the method is the same - dumping "a.methods" would help you a little if 'object' doesn't work...) -- 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] submit form in popup and send value back to the main page
I made a popup within object1's form to show another form to create a new document object to associate with object1. When I click the submit button I want 1) the document object to be created 2) the popup to close 3) the value in the document "title" field to get added to the document name field in object1's form. I've made the form for the document object in the popup but I'm having trouble figuring out the logic for 2) and 3). I'd imagine I have to use javascript to close the popup and send the title back to the main page. -- 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 reference a select_tag within a form
Thanks very much for taking another look at my problem. > If you want to use RJS then you need > to use the block form of button_to_function Here's the best my brain could come up with <%# = button_to_function("ShowList", % ) %> <%= button_to_function("ShowList") { page["vendor_droplist"].toggle } %> but compilation of new.html.erb with that change gives me: === undefined local variable or method `page' for # Extracted source (around line #17): 14: <%= f.label :vendor %> 15: <%= f.text_field :vendor %> 16: <%# = button_to_function("ShowList", % ) %> 17: <%= button_to_function("ShowList") { page["vendor_droplist"].toggle } %> 18: 19: 20: <%= select_tag "list", === If it's not too much trouble, can you point me to website that provides detail on the alternative forms, or even better, show me a correct form of #17 above. Sorry for being so obtuse ... I'm a Rails nubie, but aspiring higher :-) -- Richard On Mar 23, 4:11 am, Frederick Cheung wrote: > On 23 Mar, 07:33, RichardOnRails > > > > wrote: > > Hi Frederick, > > > As I mentioned to Colin, I would start a new thread on this question, > > which is > > athttp://groups.google.com/group/rubyonrails-talk/tree/browse_frm/threa... > > > Thanks for looking into my problem. > > > But I just noticed that there is another response on this thread. > > > > button_to_function creates a form, which would result in a form nested > > > inside a form, which isn't allowed. > > > Wow. As I mentioned on the other thread, I posted code on that > > seemed clean from a Rails perspective and from an HTML perspective. > > > So, if button_to_function is inappropriate for forms, can I specify > > an image that, when clicked, would toggle a page with the appropriate > > id specified? Is there an example on the web that you'd recommend? > > Sorry, slight mixup up; button_to creates a form, but looks like > button_to_remote doesn't. Your javscript fragment is incorrect though > - the () on a method call aren't optional in javascript, and what > you've got there looks more like RJS than javascript - the whole > page[] construct is an RJS-ism. If you want to use RJS then you need > to use the block form of button_to_function > > Fred > > > Best wishes, > > Richard > > > BTW, my current code, with HTML generated and Validation results is > > athttp://www.pastie.org/882256 > > > On Mar 22, 7:00 pm, Frederick Cheung > > wrote: > > > > On Mar 22, 9:18 pm, > > > RichardOnRails wrote: > > > > It brought up a list of vendor-names immediately under my Vendors > > > > textbox, which worked great as far as I was concerned. Then I tried > > > > to turn it into a real drop-down: > > > > 1. I added style="display:none" to the div so that the drop-down was > > > > hidden when the page opened > > > > 2. I added <%= button_to_function("ShowList", > > > > % ) %> following the text_field > > > > > Hiding the drop-down worked, but the button failed to restore it. > > > > Validating the resulting HTML revealed the a div is not permitted in > > > > the scope of a form. > > > > button_to_function creates a form, which would result in a form nested > > > inside a form, which isn't allowed. > > > > 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: Displaying a nested field as a label
This is a nested model form using to models: section and comment, where section has many comments. "text" is a field for comments "approval_boolean" is a field for comments I just want the field value for "text" to show up as a non-form- element and "approval_boolean" to show as a check box form element. The code above works, but I can only get the "text" field to show up as a text_area or text_field form element. Like I said, if <%= a.text %> worked, I'd be happy... but it gives me a method error and I'm not sure why. A! a.class = formbuilder. I thought it was a Comments class. Now I know what to look up I guess my question after all is there any way to "extract" a data value from a field within a formbuilder? (if I got my terminology right) Thanks for taking the time to look at this, btw. -a On Mar 23, 11:45 am, Michael Pavling wrote: > On 23 March 2010 16:35, andrew wrote: > > > Ok, I'll clean up the variable names. Thanks! :) > > > However > > > <%=h comment.txt %> undefined method `text' > > <%= text %> and <%=h text %> give undefined local variable or method > > `text' > > > Neither of those ideas work. :( > > Well what *is* your "a/comment" variable? Have you debugged it to see > what's going on in that block? Do you *know* what methods it's got, or > are you assuming there's a "text" method? > > You can use <% puts %> or <% logger.info %> to output > messages to help you diagnose what's going on. Personally, I prefer to > use breakpoint debugging in Netbeans. > > does 'puts a.respond_to("text")' display true? > what does 'puts a.inspect' give you? -- 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] netbeans on ubuntu
On 23 March 2010 16:47, Viorel wrote: > I just installed Netbeans 6.7 on Ubuntu 9.4 and all seems to be OK, > except I get the following error when I try rake tasks: > > Rails requires RubyGems >= 1.3.2 (you have 1.3.1). Please `gem update > --system` and try again. That should probably be sudo gem update --system Colin > > Thank you for any help > Viorel > > -- > 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] netbeans on ubuntu
On 23 March 2010 16:47, Viorel wrote: > I just installed Netbeans 6.7 on Ubuntu 9.4 and all seems to be OK, > except I get the following error when I try rake tasks: If you're installing Netbeans, what's wrong with using the latest version (6.8) > Rails requires RubyGems >= 1.3.2 (you have 1.3.1). Please `gem update > --system` and try again. and so the first thing you did was run "gem update --system" and then what happened... -- 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] netbeans on ubuntu
I just installed Netbeans 6.7 on Ubuntu 9.4 and all seems to be OK, except I get the following error when I try rake tasks: Rails requires RubyGems >= 1.3.2 (you have 1.3.1). Please `gem update --system` and try again. Thank you for any help Viorel -- 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: Displaying a nested field as a label
On 23 March 2010 16:35, andrew wrote: > Ok, I'll clean up the variable names. Thanks! :) > > However > > <%=h comment.txt %> undefined method `text' > <%= text %> and <%=h text %> give undefined local variable or method > `text' > > Neither of those ideas work. :( Well what *is* your "a/comment" variable? Have you debugged it to see what's going on in that block? Do you *know* what methods it's got, or are you assuming there's a "text" method? You can use <% puts %> or <% logger.info %> to output messages to help you diagnose what's going on. Personally, I prefer to use breakpoint debugging in Netbeans. does 'puts a.respond_to("text")' display true? what does 'puts a.inspect' give you? -- 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 do I set defaults for view parameters?
On 23 March 2010 16:31, Robin Ting wrote: > I don't, but I figure there must be a way to just have it in the > controllers. Oh well thanks, I'll start another thread. You don't what? It is best to insert your reply at the appropriate point in the comment so that it is easier to follow the thread. If you mean that you don't have the .:format in the route where you are using some_url.csv then that is the problem. Colin > > On Tue, Mar 23, 2010 at 12:17 PM, Colin Law wrote: >> On 23 March 2010 16:03, Robin Ting wrote: >>> Yeah thanks for the help! >>> >>> By the way do you know how I can get the "format.csv { render :csv => >>> @logs }" part to work? I have tested it on an index page and that >>> works, but when I try it on this admin page it says it doesn't >>> understand the URL. I have set a direct path to the admin page instead >>> of the standard "controller/action" path in the routes.rb file, but >>> even if i go through the "controller/action" path it still says it >>> can't find it. Is it because of that direct path in the routes.rb that >>> it's giving me the error? >> >> Have you got the .:format bit in the route? Otherwise I would suggest >> a new thread for this question as routing is not my high point. >> >> 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. >> >> > > -- > 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: Displaying a nested field as a label
Ok, I'll clean up the variable names. Thanks! :) However <%=h comment.txt %> undefined method `text' <%= text %> and <%=h text %> give undefined local variable or method `text' Neither of those ideas work. :( On Mar 23, 10:14 am, Colin Law wrote: > On 23 March 2010 14:55, andrew wrote: > > > That's my question! How do you do that. > > > <% a.text %> gives me this error: > > You want just > <%= text %> > or probably > <%= h text %> dependant on where text is coming from > > Colin > > > > > > > NoMethodError in Sections#edit_acknowledgments > > > Showing app/views/sections/edit_acknowledgments.html.erb where line > > #11 raised: > > > Thanks! -a > > > On Mar 23, 3:47 am, Sharagoz -- wrote: > >> If it is going to be read-only, why do you need to display it in a > >> text_area instead of directly on the page? > > >> andrew wrote: > >> > There is what I'm doing: I want to display a series of text_area > >> > fields (read only) of which each has a checkbox. > > >> > Is this the best way to do it? > > >> > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> > >> > <% f.fields_for :comments do |a|%> > >> > > >> > <%= a.text_area :text, :read_only => 'true' %> > >> > <%= a.check_box :approval_boolean %> > >> > > >> > > >> > <% end %> > >> > <% end %> > > >> > Is there any other way to display the field "text" other than above? > > >> > Thanks! > > >> -- > >> 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 > > athttp://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: How do I set defaults for view parameters?
I don't, but I figure there must be a way to just have it in the controllers. Oh well thanks, I'll start another thread. On Tue, Mar 23, 2010 at 12:17 PM, Colin Law wrote: > On 23 March 2010 16:03, Robin Ting wrote: >> Yeah thanks for the help! >> >> By the way do you know how I can get the "format.csv { render :csv => >> @logs }" part to work? I have tested it on an index page and that >> works, but when I try it on this admin page it says it doesn't >> understand the URL. I have set a direct path to the admin page instead >> of the standard "controller/action" path in the routes.rb file, but >> even if i go through the "controller/action" path it still says it >> can't find it. Is it because of that direct path in the routes.rb that >> it's giving me the error? > > Have you got the .:format bit in the route? Otherwise I would suggest > a new thread for this question as routing is not my high point. > > 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. > > -- 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: change column to allow null
cool thanks On Mar 23, 5:21 pm, Colin Law wrote: > On 23 March 2010 16:11, ES wrote: > > > Actually, I had :null=> true > > > On Mar 23, 5:01 pm, ES wrote: > >> how do I change the column in a table to allow null? > > >> I have > > >> change_column :docs, :orga, :null > > If you check the docs for change_column you will see that you need the > column type even if it has not changed > change_column :docs, :orga, whatever_type_it_is :null=>true > > Colin > > > > >> in my migration file but I get an error: > > >> Mysql::Error: You have an error in your SQL syntax; check the manual > >> that corresponds to your MySQL server version for the right syntax to > >> use near 'null DEFAULT '' NOT NULL' at line 1: ALTER TABLE `docs` > >> CHANGE `orga` `orga null DEFAULT '' NOT NULL > > > -- > > 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 > > athttp://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: change column to allow null
On 23 March 2010 16:11, ES wrote: > Actually, I had :null=> true > > On Mar 23, 5:01 pm, ES wrote: >> how do I change the column in a table to allow null? >> >> I have >> >> change_column :docs, :orga, :null If you check the docs for change_column you will see that you need the column type even if it has not changed change_column :docs, :orga, whatever_type_it_is :null=>true Colin >> >> in my migration file but I get an error: >> >> Mysql::Error: You have an error in your SQL syntax; check the manual >> that corresponds to your MySQL server version for the right syntax to >> use near 'null DEFAULT '' NOT NULL' at line 1: ALTER TABLE `docs` >> CHANGE `orga` `orga null DEFAULT '' NOT NULL > > -- > 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: How do I set defaults for view parameters?
On 23 March 2010 16:03, Robin Ting wrote: > Yeah thanks for the help! > > By the way do you know how I can get the "format.csv { render :csv => > @logs }" part to work? I have tested it on an index page and that > works, but when I try it on this admin page it says it doesn't > understand the URL. I have set a direct path to the admin page instead > of the standard "controller/action" path in the routes.rb file, but > even if i go through the "controller/action" path it still says it > can't find it. Is it because of that direct path in the routes.rb that > it's giving me the error? Have you got the .:format bit in the route? Otherwise I would suggest a new thread for this question as routing is not my high point. 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: change column to allow null
Actually, I had :null=> true On Mar 23, 5:01 pm, ES wrote: > how do I change the column in a table to allow null? > > I have > > change_column :docs, :orga, :null > > in my migration file but I get an error: > > Mysql::Error: You have an error in your SQL syntax; check the manual > that corresponds to your MySQL server version for the right syntax to > use near 'null DEFAULT '' NOT NULL' at line 1: ALTER TABLE `docs` > CHANGE `orga` `orga null DEFAULT '' NOT NULL -- 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 do I set defaults for view parameters?
Yeah thanks for the help! By the way do you know how I can get the "format.csv { render :csv => @logs }" part to work? I have tested it on an index page and that works, but when I try it on this admin page it says it doesn't understand the URL. I have set a direct path to the admin page instead of the standard "controller/action" path in the routes.rb file, but even if i go through the "controller/action" path it still says it can't find it. Is it because of that direct path in the routes.rb that it's giving me the error? On Tue, Mar 23, 2010 at 11:24 AM, Colin Law wrote: > On 23 March 2010 15:20, Robin Ting wrote: >> Well that's strange then, because it still gave me a unexpected nil >> found error when I use that. Actually now that I think about it, I >> might have been using it on params[:find_dates]['start_date(1i)'] >> instead of just the params[:find_dates]. > > That would explain it, params[:find_dates]['start_date(1i)'] == nil > would generate an error if params[:find_dates] is nil because it would > attempt to evaluate nil.['start_date(1i)'] first. > > 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. > > -- 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] change column to allow null
how do I change the column in a table to allow null? I have change_column :docs, :orga,:null in my migration file but I get an error: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null DEFAULT '' NOT NULL' at line 1: ALTER TABLE `docs` CHANGE `orga` `orga null DEFAULT '' NOT NULL -- 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 number of assertions in test output
Hi, I did a number of test runs from the book Agile Web Development with Rails, third edition, (chapter 14, Task T: Testing). I use Netbeans 6.8 as IDE. All the test output runs are missing the number of assertions. For example: |Finished in 0,733 seconds. 5 tests, 0 failures, 0 errors| However in this example, 6 assertions were tested and I expected: |Finished in 0,733 seconds. 5 tests, 6 assertions, 0 failures, 0 errors| Can anyone give me a clue why the assertions are missing in the output? Thanks in advance, Thiel -- 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 to parse a User uploaded file, but don't care if it's saved
One way would be to just process the uploaded-file data from the request as needed and not worry about saving or doing anything else with the tmp-saved uploaded-file itself, something like: ### in ./app/models/uploadable_file.rb class UploadableFile ### for use in testing: def initialize(fname, contents) @fname = fname @contents = contents end def original_filename return @fname end def read return @contents end ### class meths: def self.parse(upfile) return nil if upfile.blank? or not (upfile.respond_to? ('original_filename')\ and upfile.respond_to?('read')) orig_fname = upfile.original_filename contents = upfile.read # parse/process contents end end Then just call that class meth in your controller to parse the uploaded file for an example file form element of name "upfile": ### in some controller meth that handles that multipart/form-data form: ... parsed_contents = UploadableFile.parse(params[:upfile]) # check results Jeff On Mar 22, 9:37 pm, GoodGets wrote: > parsing the file's not the problem, just not sure what to do with it > before or after. I was thinking about uploading the files using > Paperclip, parsing it, then deleting itfrom the database. But, that > all seems a little unnecessary, especially if I don't care if they are > even saved. > > I then thought about grabbing them from the temp directory, but > honestly wasn't sure how to go about doing that. So before I really > delve into the Tempfile, should I even worry about it in the first > place? Each user uploaded file will be like 30kb max, and I'll only > be processing a couple hundred a month. Also, I'm hosted on heroku, > so the s3 transfers (if I do save the file) will be free. What ya > think? > > Any advice really is 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] Frozen hash problem
I'd like to delete some records before saving them. I ran this experiment: before_save :prune_lab_datas def prune_lab_datas lab_datas.each do |lab_data| lab_data.destroy end raise lab_datas.to_yaml end But nothing seems to be deleted in the hash: --- - &id001 !ruby/object:LabData attributes: created_at: 2010-03-21 22:16:06 unit_id: "3" lab_id: "81" updated_at: 2010-03-21 22:16:06 id: "184" lab_desc_id: "6" value: "29" attributes_cache: {} changed_attributes: {} errors: !ruby/object:ActiveRecord::Errors base: *id001 errors: {} And if I remove the "raise", the controller throws a "can't modify frozen hash" error. Any idea how I can remove records from the hash prior to saving? TIA, Craig -- 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 do I set defaults for view parameters?
On 23 March 2010 15:20, Robin Ting wrote: > Well that's strange then, because it still gave me a unexpected nil > found error when I use that. Actually now that I think about it, I > might have been using it on params[:find_dates]['start_date(1i)'] > instead of just the params[:find_dates]. That would explain it, params[:find_dates]['start_date(1i)'] == nil would generate an error if params[:find_dates] is nil because it would attempt to evaluate nil.['start_date(1i)'] first. 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: Default pricing and custom client pricing
On 23 March 2010 15:08, Craig White wrote: > On Tue, 2010-03-23 at 08:53 +, Colin Law wrote: >> On 23 March 2010 02:15, Craig White wrote: >> > On Tue, 2010-03-23 at 03:02 +0100, Tony Tony wrote: >> >> Craig White wrote: >> >> >> >> > I would have a table called pricing and have a column that had the >> >> > customer_id and thus you might have 2 (or more) prices for an item but >> >> > only one for a specific customer or default to the one that is not tied >> >> > to a specific customer. >> >> >> >> Hi Craig! >> >> >> >> I don't think this would work as there are quite a number of clients >> >> (over 25) who currently have a different price per product. In the >> >> future there might be additional clients with custom pricing depending >> >> on how much volume they push. >> >> >> >> If I were to implement your suggestion I would have to have 25+ fields >> >> (pricing_1, pricing_2, pricing_3, etc.) which I don't think is the >> >> correct approach for this. Did I misunderstand your suggestion? >> > >> > yes, you misunderstood... sorry if I wasn't clear enough. Something like >> > this, definitely not tested and perhaps you can get it down to a single >> > query. >> > >> > Class Pricing >> > has_one :customer >> > belongs_to :item >> >> Should that be belongs_to: customer rather than has_one, along with >> customer has_many pricings, and item has_many pricings? >> I would have used class Price rather then Pricings but that is a >> matter of personal preference. > > that's an interesting question and probably reflects on the fuzziness of > my understanding of the difference between belongs_to and has_one. While > I can clearly see that the intent is that the difference is which table > has the referencing id, I tend to think of belongs_to as a 'must' and > has_one as a 'may' and in my original answer, I was contemplating a > price for each item that was not associated with any customer. If it > were left to me, I would probably create a 'retail' customer and > actually indicated that in my follow up answer. > The relationships are has_many and belongs_to or has_one and belongs_to. In both cases the belongs_to is the one with the foreign key. In this case since Customer has_many Prices, it must be Price belongs_to Customer. Colin >> >> > >> > id >> > price >> > customer_id >> >> You will need an item_id also > > yes > >> > >> > def self.item_price(item, customer) >> > if Price.find(:first, :conditions => ["item_id = ? AND customer_id >> > = ?", item, customer']) then >> > return Price.find(:first, :conditions => ["item_id = ? AND >> > customer_id = ?", item, customer']).price >> > else >> > return Price.find(:first, :conditions => ["item_id = ? AND >> > customer_id = NULL", item]).price >> > end >> > end >> >> This could be done as a named scope which might make for a neater solution. > > probably true and probably how I would end up doing it. It was just a > top of my head answer and the defined method could easily be converted > into a named_scope. > > Craig > > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. > > -- > 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: How do I set defaults for view parameters?
Well that's strange then, because it still gave me a unexpected nil found error when I use that. Actually now that I think about it, I might have been using it on params[:find_dates]['start_date(1i)'] instead of just the params[:find_dates]. On Tue, Mar 23, 2010 at 11:12 AM, Colin Law wrote: > On 23 March 2010 15:04, Civ2boss wrote: >> Thanks that works! I was trying params[:find_dates] == nil, > > params[:find_dates] == nil is the same as params[:find_dates].nil? > > 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. > > -- 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: Displaying a nested field as a label
On 23 March 2010 14:55, andrew wrote: > That's my question! How do you do that. > > <% a.text %> gives me this error: You want just <%= text %> or probably <%= h text %> dependant on where text is coming from Colin > > NoMethodError in Sections#edit_acknowledgments > > Showing app/views/sections/edit_acknowledgments.html.erb where line > #11 raised: > > Thanks! -a > > On Mar 23, 3:47 am, Sharagoz -- wrote: >> If it is going to be read-only, why do you need to display it in a >> text_area instead of directly on the page? >> >> >> >> >> >> andrew wrote: >> > There is what I'm doing: I want to display a series of text_area >> > fields (read only) of which each has a checkbox. >> >> > Is this the best way to do it? >> >> > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> >> > <% f.fields_for :comments do |a|%> >> > >> > <%= a.text_area :text, :read_only => 'true' %> >> > <%= a.check_box :approval_boolean %> >> > >> > >> > <% end %> >> > <% end %> >> >> > Is there any other way to display the field "text" other than above? >> >> > Thanks! >> >> -- >> 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. > > -- 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: Default pricing and custom client pricing
On Tue, 2010-03-23 at 08:53 +, Colin Law wrote: > On 23 March 2010 02:15, Craig White wrote: > > On Tue, 2010-03-23 at 03:02 +0100, Tony Tony wrote: > >> Craig White wrote: > >> > >> > I would have a table called pricing and have a column that had the > >> > customer_id and thus you might have 2 (or more) prices for an item but > >> > only one for a specific customer or default to the one that is not tied > >> > to a specific customer. > >> > >> Hi Craig! > >> > >> I don't think this would work as there are quite a number of clients > >> (over 25) who currently have a different price per product. In the > >> future there might be additional clients with custom pricing depending > >> on how much volume they push. > >> > >> If I were to implement your suggestion I would have to have 25+ fields > >> (pricing_1, pricing_2, pricing_3, etc.) which I don't think is the > >> correct approach for this. Did I misunderstand your suggestion? > > > > yes, you misunderstood... sorry if I wasn't clear enough. Something like > > this, definitely not tested and perhaps you can get it down to a single > > query. > > > > Class Pricing > > has_one :customer > > belongs_to :item > > Should that be belongs_to: customer rather than has_one, along with > customer has_many pricings, and item has_many pricings? > I would have used class Price rather then Pricings but that is a > matter of personal preference. that's an interesting question and probably reflects on the fuzziness of my understanding of the difference between belongs_to and has_one. While I can clearly see that the intent is that the difference is which table has the referencing id, I tend to think of belongs_to as a 'must' and has_one as a 'may' and in my original answer, I was contemplating a price for each item that was not associated with any customer. If it were left to me, I would probably create a 'retail' customer and actually indicated that in my follow up answer. > > > > > id > > price > > customer_id > > You will need an item_id also yes > > > > def self.item_price(item, customer) > > if Price.find(:first, :conditions => ["item_id = ? AND customer_id > > = ?", item, customer']) then > >return Price.find(:first, :conditions => ["item_id = ? AND > > customer_id = ?", item, customer']).price > > else > >return Price.find(:first, :conditions => ["item_id = ? AND > > customer_id = NULL", item]).price > > end > > end > > This could be done as a named scope which might make for a neater solution. probably true and probably how I would end up doing it. It was just a top of my head answer and the defined method could easily be converted into a named_scope. Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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 do I set defaults for view parameters?
On 23 March 2010 15:04, Civ2boss wrote: > Thanks that works! I was trying params[:find_dates] == nil, params[:find_dates] == nil is the same as params[:find_dates].nil? 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: Displaying a nested field as a label
On 23 March 2010 14:55, andrew wrote: > That's my question! How do you do that. > > <% a.text %> gives me this error: <%=h a.text %> BTW, "a" is not a very helpful name for a block variable (or any variable for that matter). Assuming you're not paying for your code by the byte, it would be more legible thus: <% f.fields_for :comments do |comment|%> ... <%=h comment.text %> YMMV -- 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 do I set defaults for view parameters?
Thanks that works! I was trying params[:find_dates] == nil, params[:find_dates].blank?, params[:find_dates] == " ", but obviously none of them worked. Here's an sort of off-topic question how would I go about getting format.csv { render :csv => @logs } to work? Rails gives a method not found error. I did use the routes.rb file to give that admin page a direct link, but even if I use the full "controller/action" url, it still says not found. Do I need to give that a direct link in the routes.rb file also or am I missing something? On Mar 22, 4:11 pm, "E. Litwin" wrote: > params[:find_dates].nil? > > On Mar 22, 12:22 pm, Civ2boss wrote: > > > How would I go about testing the parameter? > > > On Mar 22, 1:35 pm, Colin Law wrote: > > > > On 22 March 2010 16:34, Civ2boss wrote: > > > > > So I am making a rails app that lets users search logs by date. So in > > > > my controller I have set it to look for logs from the DB using the > > > > parameters. However when it first loads, there are no parameters > > > > passed to the controller, so it gives a nil error. > > > > > Is there a way to set the default parameters so that it won't have > > > > this error? > > > > > Here are the controller and view snippets: > > > > > user_sessions_controller.rb > > > > > [...] > > > > def admin > > > > > �...@start_date = Date::civil(params[:find_dates] > > > > ['start_date(1i)'].to_i, params[:find_dates]['start_date(2i)'].to_i, > > > > params[:find_dates]['start_date(3i)'].to_i) > > > > Test params[:find_dates] before you use it and take appropriate action if > > > nil. > > > > Colin > > > > > �...@end_date = Date::civil(params[:find_dates]["end_date(1i)"].to_i, > > > > params[:find_dates]["end_date(2i)"].to_i, params[:find_dates] > > > > ["end_date(3i)"].to_i) > > > > > �...@logs = Log.all(:conditions => ["updated_at between ? and ?", > > > > @start_date, @end_date], :order => "updated_at DESC") > > > > > respond_to do |format| > > > > format.html { render :action => 'admin' } > > > > format.csv { render :csv => @logs } > > > > end > > > > > end > > > > [...] > > > > > admin.html.erb > > > > > [...] > > > > > > > > <% form_tag '/find_dates' do %> > > > > > > > > <%= label_tag "start_date", "Start Date" %> > > > > <%= date_select "find_dates", "start_date", > > > > :order => > > > > [:month, :day, :year] %> > > > > > > > > > > > > <%= label_tag "end_date", "End Date" %> > > > > <%= date_select "find_dates", "end_date", :order > > > > => > > > > [:month, :day, :year] %> > > > > > > > > <%= submit_tag "Find" %> > > > > <% end %> > > > > > > > > [...] > > > > > -- > > > > 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 > > > > athttp://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: Displaying a nested field as a label
That's my question! How do you do that. <% a.text %> gives me this error: NoMethodError in Sections#edit_acknowledgments Showing app/views/sections/edit_acknowledgments.html.erb where line #11 raised: Thanks! -a On Mar 23, 3:47 am, Sharagoz -- wrote: > If it is going to be read-only, why do you need to display it in a > text_area instead of directly on the page? > > > > > > andrew wrote: > > There is what I'm doing: I want to display a series of text_area > > fields (read only) of which each has a checkbox. > > > Is this the best way to do it? > > > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> > > <% f.fields_for :comments do |a|%> > > > > <%= a.text_area :text, :read_only => 'true' %> > > <%= a.check_box :approval_boolean %> > > > > > > <% end %> > > <% end %> > > > Is there any other way to display the field "text" other than above? > > > Thanks! > > -- > 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] regular expression
$ irb >> "module$block.item"[/\$(.*?)\./, 1] => "block" Cheers, Andy -- Andy Jeffries http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS Company number: 5452840 On 23 March 2010 14:03, Marcio Machado wrote: > Hi, > > I´m trying to write a regular expression to get the substring "block" > in: > "module$block.item" > > I´ve reached the obvious /\$.*\./ witch returns "$block." substring. > > How do I get directly the "block" substring? > -- > 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.
[Rails] regular expression
Hi, I´m trying to write a regular expression to get the substring "block" in: "module$block.item" I´ve reached the obvious /\$.*\./ witch returns "$block." substring. How do I get directly the "block" substring? -- 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: Newbie needing help on some tricky associations
On 23 March 2010 12:58, Andy wrote: > Of course! Thanks very much or your replies, I really appreciate it. > > The app is an administrative tool, not a front end webstore. Sorry I > wasn't more clear upfront, Sharagoz. The user will need to be able to > create three types of items in the system via (nested model) forms: > MenuItems, RecipeItems, and PurchaseItems. Ingredients are not a > specific model that a user would have to interact with, as the > RecipeItems and PurchaseItems are the Ingredients of other RecipeItems > or MenuItems. I thought Ingredient would be an important object for > the application as the name of the join model to link these items, > however if another approach is recommended I am not hard set in this > logic of course. > > The end result will be similar to many of the 'add task to project/add > questions and answers to survey' nested model forms there are numerous > tutorials for, but the associations just don't seem as > straightforward. > > For a MenuItem form the user should be able to add and remove > RecipeItems or PurchaseItems as Ingredients of the MenuItem (with > details like quantity as well that are particular to the join). > > For a RecipeItem form the user should be able to add and remove > RecipeItems or PurchaseItems as Ingredients of the RecipeItem (again, > with details like quantity as well that are particular to the join). > > PurchaseItems only need to be created as they are at the bottom of the > chain so to speak and don't contain other items. > > For example, Flour might be a purchaseitem, Pasta Dough might be a > RecipeItem, and Spaghetti might be a Menuitem. Colin, the RecipeItems > technically are the recipes you might say, as the ingredients are > tacked to them and there will be fields for instructions in the > RecipeItem model as well. I still think you are starting off too deep in the implementation and may not have got the basic models arranged optimally. You have described what you want your application wants to do in computer terms but still have not described the real-world situation that you are modelling. For example you say "the RecipeItems technically are the recipes you might say, as the ingredients are tacked to them and there will be fields for instructions in the RecipeItem model as well". So in the real world are there recipes? If so what are their attributes? Does a recipe have Ingredients for example? 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: ActiveMerchant, Authorize.net and Email Receipts
> add_customer_data is called within purchase to process its options > hash. My question is in reference to the line that processes the email > key: Why on earth does it, after checking to see if the email entry > exists, set customer_email explicitly to false? No idea, probably either it was easier, it wouldn't fit with their gateway api (i.e. other vendors might not have that functionality), it worked for them at the time. Have you tried overriding it in your own app? You could always submit a patch to https://jadedpixel.lighthouseapp.com/projects/11599-active-merchant/tickets :) 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: Newbie needing help on some tricky associations
Of course! Thanks very much or your replies, I really appreciate it. The app is an administrative tool, not a front end webstore. Sorry I wasn't more clear upfront, Sharagoz. The user will need to be able to create three types of items in the system via (nested model) forms: MenuItems, RecipeItems, and PurchaseItems. Ingredients are not a specific model that a user would have to interact with, as the RecipeItems and PurchaseItems are the Ingredients of other RecipeItems or MenuItems. I thought Ingredient would be an important object for the application as the name of the join model to link these items, however if another approach is recommended I am not hard set in this logic of course. The end result will be similar to many of the 'add task to project/add questions and answers to survey' nested model forms there are numerous tutorials for, but the associations just don't seem as straightforward. For a MenuItem form the user should be able to add and remove RecipeItems or PurchaseItems as Ingredients of the MenuItem (with details like quantity as well that are particular to the join). For a RecipeItem form the user should be able to add and remove RecipeItems or PurchaseItems as Ingredients of the RecipeItem (again, with details like quantity as well that are particular to the join). PurchaseItems only need to be created as they are at the bottom of the chain so to speak and don't contain other items. For example, Flour might be a purchaseitem, Pasta Dough might be a RecipeItem, and Spaghetti might be a Menuitem. Colin, the RecipeItems technically are the recipes you might say, as the ingredients are tacked to them and there will be fields for instructions in the RecipeItem model as well. Thanks for your time to help a newb! It's frustrating to not be using the cooler features of Rails when you're stuck on the model mapping ;) -Andy -- 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: Question on insert to multiple tables?
You are probably better of posting on the activescaffold group: http://groups.google.com/group/activescaffold Unfortunately their documentation site is down at the moment but I'm pretty sure they describe how to do model associations in activescaffold. http://activescaffold.com/docs To be honest if you are a beginner I wouldn't recommend starting out on activescaffold - get the Agile Web Development with Rails book and learn the fundamentals first: http://www.pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition 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: Extract shapes and text from images
comopasta Gr wrote: > Hi, any hints anybody? > Or some references how could that be implemented? My guess is that you'll need to ask this on a forum more focused on OCR and graphics processing. This question is not specific to Rails. -- 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: Extract shapes and text from images
Hi, any hints anybody? Or some references how could that be implemented? Cheers. -- 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: Still Using old Rails even after Upgrade
On 23 March 2010 11:30, jackster the jackle wrote: > that worked but now I'm getting What worked? If you trim the whole previous message, no one knows what you're replying to... > require_frameworks': no such file to load -- openssl (RuntimeError) > > when I try to run Webrick. > > From what I'm reading, I need to install openssl-dev >From what I've seen of posts from people with the same problem, that does seem to form part of the answer. > Do you guys recommend that I run Rails under Apache or through Webrick? For development or live servers? For live, I'd certainly avoid Webrick, as Apache/Passenger or NGinx is much better/faster/easier/reliable. Although to be honest, for development I avoid Webrick to, and use Mongrel :-) -- 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: Still Using old Rails even after Upgrade
that worked but now I'm getting require_frameworks': no such file to load -- openssl (RuntimeError) when I try to run Webrick. >From what I'm reading, I need to install openssl-dev but since this is a hosting server, I don't have access to a package handler so I contacted web support. Do you guys recommend that I run Rails under Apache or through Webrick? thanks jack -- 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] Newbie needing help on some tricky associations
On 23 March 2010 05:27, Andy wrote: > Hello, > I'm stuck on some associations that I think may be more complex than I > originally anticipated. Not really straightforward stuff for my first > Rails app so if you have a chance to point me in the right direction I > would really appreciate it!! > > I have PurchaseItems, RecipeItems, and MenuItems. > PurchaseItems can be an Ingredient of RecipeItems and/or MenuItems. > RecipeItems can be an Ingredient of other RecipeItems and/or > MenuItems. > > I need to track additional Ingredient-specific attributes as well so > it seems that a has_many :through association is required. I can get > simple examples of this working just fine if I remove other parts of > the logic, but am just dying here trying to get it all to work > together. There is clearly self-referential associations at play here > also and (maybe??) polymorphic as well. You need to explain your objects more clearly. Try and explain the real world problem first, what are the objects in the real world? I would have expected to see Recipes in there for example, not just RecipeItems. Also are there no Ingredient objects? Colin 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: Newbie needing help on some tricky associations
It's hard for us to help you with the associations when you arent describing what you're trying to make. Im gonna try to guess based on what you've given: This is going to be a web shop with products related to cooking. A bunch of products (in this case ingredients) can be put together as a recipe. And obviously, since this is a store, a bunch of products can be put together as an order (purchase) as well. Correct? What exactly is a "menu_item"? On Mar 23, 6:27 am, Andy wrote: > Hello, > I'm stuck on some associations that I think may be more complex than I > originally anticipated. Not really straightforward stuff for my first > Rails app so if you have a chance to point me in the right direction I > would really appreciate it!! > > I have PurchaseItems, RecipeItems, and MenuItems. > PurchaseItems can be an Ingredient of RecipeItems and/or MenuItems. > RecipeItems can be an Ingredient of other RecipeItems and/or > MenuItems. > > I need to track additional Ingredient-specific attributes as well so > it seems that a has_many :through association is required. I can get > simple examples of this working just fine if I remove other parts of > the logic, but am just dying here trying to get it all to work > together. There is clearly self-referential associations at play here > also and (maybe??) polymorphic as well. > > I would be completely thrilled if someone who has done this more than > once could help me out and illustrate the appropriate model > associations. > > Thanks for your time!! > -Andy -- 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: Blank Log Files - New to RoR - Ubuntu Server 9.10
On 23 March 2010 09:57, Michael Pavling wrote: > On 22 March 2010 14:11, Justin wrote: >> I didn't know about www-data, but your suggestion still didn't work. I just checked a server I have here (Ubuntu 9.04LTS) and the directory ownership is slightly different to what I said. I've got it as: chown -R root.www-data my_rails_app Also worth checking the permissions of the log folder, and if there's log files in there, check their perms - delete them if necessary and see if the app recreates them once all the ownership is set. -- 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: Blank Log Files - New to RoR - Ubuntu Server 9.10
On 22 March 2010 14:11, Justin wrote: > I didn't know about www-data, but your suggestion still didn't work. I > rebooted the server completely. I still get the blank logs. Also, I > still get the correct Welcome Aboard page, but when I click "About > your application's environment", I still get "We're sorry, but > something went wrong". There's only one installation of rails on the > server, so I know this must be it. I'd focus on trying to get the logs populating first... any other problems are not going to be easier to fix without it - and you might find that whatever problem is causing the log-files not to get written might be causing others Did you try accessing your models in the console? What was the outcome to that? You may get a hint that pushes you in the right direction. Anyway, the idea to change the owner of the files is more general than specific; I'm assuming your server's using the www-data user to run the site - if it's a different user, the ownership needs to be different. Anything in the Apache error logs? -- 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 to parse a User uploaded file, but don't care if it's saved
Sorry just to add that tutorial saves it in a model - but obviously you don't need to do that. -- 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 to parse a User uploaded file, but don't care if it's saved
Don't know if this is any use - but you could just upload it yourself (rather than using paperclip or file_column): http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm You can choose the directory that you want it saved in, then delete the file as soon as you are done with it. 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: Saas design considerations
hi saljamil > and its children. I used named scopes in the model to pass the user_id > from controller and get back data specific to that user (his org and > children orgs). Send me an email if you need some code examples. I would like to get some code examples. Please send your mailid. My id is to.tom.mak at gmail.com 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.
Re: [Rails] Re: How to reference a select_tag within a form
On 22 March 2010 22:32, RichardOnRails wrote: > Hi Colin, > > I still don't have subversion not git working. Well the answer to that problem is obvious. Colin > But I pretty sure that > http://www.pastie.org/881730 presents it all: three aspects of "new > expenses": the .erb, the htm and the validator's. > > A second look a the validation failure led me to think that > substituting object for div would solve my problem. It doesn't run > any differently. I haven't sought the validator's opinion yet. > > Regards, > Richard > > On Mar 22, 5:49 pm, Colin Law wrote: >> On 22 March 2010 21:18, RichardOnRails >> >> >> >> wrote: >> > Hi All, >> >> > Inside my app\views\expenses\new.html.erb file, I had the code: >> >> > <% form_for(@expense) do |f| %> >> > [snip] >> > >> > <%= f.label :vendor %> >> > <%= f.text_field :vendor %> >> > >> > > > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> > >> > >> >> > It brought up a list of vendor-names immediately under my Vendors >> > textbox, which worked great as far as I was concerned. Then I tried >> > to turn it into a real drop-down: >> > 1. I added style="display:none" to the div so that the drop-down was >> > hidden when the page opened >> > 2. I added <%= button_to_function("ShowList", >> > % ) %> following the text_field >> >> > Hiding the drop-down worked, but the button failed to restore it. >> > Validating the resulting HTML revealed the a div is not permitted in >> > the scope of a form. >> >> You certainly can have divs inside a form. I think you must have >> misinterpreted the message. Can you roll your version control system >> back to the version that caused this and post the results of the >> validation and the bit of html causing the problem. >> >> Colin >> >> >> >> > To solve this I removed the opening and closing tags and: >> > 1. added the id to the select_tag: >> > <%= select_tag "test" :id="vendor_droplist", >> > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> > 2 added it with a comma >> > <%= select_tag "test", :id="vendor_droplist", >> > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> >> > Neither these nor any other change I tried worked. So what's the >> > Rail's way of solving this problem? >> >> > I'm running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6, MySQL >> > 5.0.37-community-nt, Mongrel. >> >> > Thanks in Advance, >> > Richard >> >> > -- >> > 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 >> > athttp://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: Stored Procedures MYSQL and Rails 2.3.2
>From the script/console: $ script/console Loading development environment (Rails 2.3.5) /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement >> ActiveRecord::Base.connection.active? => true >> User.all.size => 2 >> ActiveRecord::Base.connection.active? => true >> ActiveRecord::Base.connection.execute("CALL proc01") => # >> ActiveRecord::Base.connection.execute("CALL proc01") ActiveRecord::StatementInvalid: Mysql::Error: Commands out of sync; you can't run this command now: CALL proc01 from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute' from (irb):5 >> ActiveRecord::Base.connection.active? => false >> ActiveRecord::Base.connection.reconnect! => nil >> ActiveRecord::Base.connection.execute("CALL proc01") => # >> ActiveRecord::Base.connection.active? => false >> ActiveRecord::Base.connection.reconnect! => nil >> ActiveRecord::Base.connection.execute("CALL proc01") => # >> ActiveRecord::Base.connection.reconnect! => nil >> ActiveRecord::Base.connection.execute("CALL proc01") => # It looks like CALLing a stored procedure will drop a ActiveRecord connection. Maybe a "reconnect! if !active?" can be a quick patch... p.s. there is a ticket: https://rails.lighthouseapp.com/projects/8994/tickets/3151-mysql-adapter-update-to-enable-use-of-stored-procedures (not tried yet) -- 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: Default pricing and custom client pricing
On 23 March 2010 02:15, Craig White wrote: > On Tue, 2010-03-23 at 03:02 +0100, Tony Tony wrote: >> Craig White wrote: >> >> > I would have a table called pricing and have a column that had the >> > customer_id and thus you might have 2 (or more) prices for an item but >> > only one for a specific customer or default to the one that is not tied >> > to a specific customer. >> >> Hi Craig! >> >> I don't think this would work as there are quite a number of clients >> (over 25) who currently have a different price per product. In the >> future there might be additional clients with custom pricing depending >> on how much volume they push. >> >> If I were to implement your suggestion I would have to have 25+ fields >> (pricing_1, pricing_2, pricing_3, etc.) which I don't think is the >> correct approach for this. Did I misunderstand your suggestion? > > yes, you misunderstood... sorry if I wasn't clear enough. Something like > this, definitely not tested and perhaps you can get it down to a single > query. > > Class Pricing > has_one :customer > belongs_to :item Should that be belongs_to: customer rather than has_one, along with customer has_many pricings, and item has_many pricings? I would have used class Price rather then Pricings but that is a matter of personal preference. Colin > > id > price > customer_id You will need an item_id also > > def self.item_price(item, customer) > if Price.find(:first, :conditions => ["item_id = ? AND customer_id > = ?", item, customer']) then > return Price.find(:first, :conditions => ["item_id = ? AND > customer_id = ?", item, customer']).price > else > return Price.find(:first, :conditions => ["item_id = ? AND > customer_id = NULL", item]).price > end > end This could be done as a named scope which might make for a neater solution. 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: Displaying a nested field as a label
If it is going to be read-only, why do you need to display it in a text_area instead of directly on the page? andrew wrote: > There is what I'm doing: I want to display a series of text_area > fields (read only) of which each has a checkbox. > > Is this the best way to do it? > > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> > <% f.fields_for :comments do |a|%> > > <%= a.text_area :text, :read_only => 'true' %> > <%= a.check_box :approval_boolean %> > > > <% end %> > <% end %> > > Is there any other way to display the field "text" other than above? > > 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: Adding items in groups in Rails
Seems a little odd what you are doing however to answer your question: You can add a text_field_tag or a select_tag to your form http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001731 e.g. <%=text_field_tag :quantity%> You can then get that via params[:quantity] in your controller from there you can either pass to your model/business logic class or do a simple: 1.upto(params[:quantity].to_i) do |i| Product.create!(params[:product]) end Personally though I would seriously consider relooking at the way you are working and perhaps normalize your data so you have 3 models: location has_many :products type has_many :products product belongs_to :location belongs_to :type Then you can do the reverse and use fields_for to add multiple products to a location. Similar to this (http://railscasts.com/episodes/196-nested-model-form-part-1) 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.
Re: [Rails] Re: Re: Re: Issues RUNNING mysql gem
On 22 March 2010 22:16, Mike Montagne wrote: > Colin Law wrote: >> >> In the case of MySql I believe that the length of a varchar only >> specifies the maximum length, it does not affect the actual space used >> in the db as the data is stored as variable length records. I don't >> know about postgresql. > If that were the case, there would be little if any reasonable purpose > in specifying VARCHAR() length. What you say may apply to the various > text field types, as a buffer of the maximum length would handle a field > of any length up to the maximum length... and the data could (best) be > stored as the variable length stream -- thus conserving disk space. See http://dev.mysql.com/doc/refman/5.1/en/char.html which clearly states that the space in the db to store a varchar is dependant on the actual length of each string, not the max permitted length. Therefore reducing the limit on a varchar column does not save space in the db. (Assuming the strings themselves are not truncated by changing the limit of course). 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: Adding items in groups in Rails
I think it makes most sence to have a "stock" field in the database, instead of having one record per stock item. > how to pass such nonmodel html/javascript fields from view > to rails and then back to the view You mean "non database" fields, right? Add this to the model: attr_accessor :attribute_name Then you can use this field like any other field, except that it wont be stored in the database. -- 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: Presentation Ideas
MVC, DRY, convention over configuration. Those are important concepts in rails. However, in a presentation a lenghtly talk about these things are probably going to be pretty boring. And its not something that student programmers may apprechiate as much as experienced programmers. I would spend a short amount of time on that and then move on to showing actual code. Stuff that looks a bit impressive, like the ajax helpers, model validation, how to interact with the database without writing any SQL. Josh Cheek wrote: > Hi, I'm going to give a talk on Rails to my campus ACM group in about > two > weeks. I'm trying to think of ideas. The 15 minute blog is great, and > I'd > kind of like to do something like that, but I can't do better than DHH > or > Ryan have, and if they look into it more, they'll come across that > pretty > quickly. > > I can do some live examples like that, or I can do a keynote / > powerpoint > style presentation. > > Does anyone have any ideas for something simple enough to go through in > an > hour, for someone with intermediate Rails skills, that would give a > basic > idea of how Rails works? > > If you were going to give a presentation, what kinds of things would you > talk about? My audience will mostly be non web developers, and the web > developers that will be there will mostly be php and possibly Java. > They'll > all be CS students, grad and undergrad, possibly a professor or two, but > not > very likely. Maybe 20-30 people. > > Any ideas or advice are welcome, thanks :) > -Josh -- 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] ActsAsTaggableOn scoped to Account
Hi, Can anybody give me some clues how to use ActsAsTaggableOn in an Account scoped way? ie. I want several accounts each to have their own sets of tags to tag their own articles rather than sharing a giant pool of tags. Or perhaps there is a better solution than ActsAsTaggableOn? Thanks! -- 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 reference a select_tag within a form
On 23 Mar, 07:33, RichardOnRails wrote: > Hi Frederick, > > As I mentioned to Colin, I would start a new thread on this question, > which is > athttp://groups.google.com/group/rubyonrails-talk/tree/browse_frm/threa... > > Thanks for looking into my problem. > > But I just noticed that there is another response on this thread. > > > button_to_function creates a form, which would result in a form nested > > inside a form, which isn't allowed. > > Wow. As I mentioned on the other thread, I posted code on that > seemed clean from a Rails perspective and from an HTML perspective. > > So, if button_to_function is inappropriate for forms, can I specify > an image that, when clicked, would toggle a page with the appropriate > id specified? Is there an example on the web that you'd recommend? > Sorry, slight mixup up; button_to creates a form, but looks like button_to_remote doesn't. Your javscript fragment is incorrect though - the () on a method call aren't optional in javascript, and what you've got there looks more like RJS than javascript - the whole page[] construct is an RJS-ism. If you want to use RJS then you need to use the block form of button_to_function Fred > Best wishes, > Richard > > BTW, my current code, with HTML generated and Validation results is > athttp://www.pastie.org/882256 > > On Mar 22, 7:00 pm, Frederick Cheung > wrote: > > > > > On Mar 22, 9:18 pm, > > RichardOnRails wrote: > > > It brought up a list of vendor-names immediately under my Vendors > > > textbox, which worked great as far as I was concerned. Then I tried > > > to turn it into a real drop-down: > > > 1. I added style="display:none" to the div so that the drop-down was > > > hidden when the page opened > > > 2. I added <%= button_to_function("ShowList", > > > % ) %> following the text_field > > > > Hiding the drop-down worked, but the button failed to restore it. > > > Validating the resulting HTML revealed the a div is not permitted in > > > the scope of a form. > > > button_to_function creates a form, which would result in a form nested > > inside a form, which isn't allowed. > > > 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: h() method in form partial
On 23 Mar, 07:46, Tom Mac wrote: > Hi > I have a doubt. Dont know it is valid. Just asking. I am trying to > reuse the same partial _form for both new and edit. So from new.html.erb > I call partial like > Well it is valid but not useful - The label help would generate something like {:f => f}%> > > and in _user_fields.html.erb an example field as > > > <%= u.label :first_name,'First Name' %> > <%= u.text_field :first_name,:maxlength => 50 %> > > > My question is if I call this same partial in edit.html.erb also, > how can I apply the h() method like below (since this fields being > populated with value from db being an edit form) > > > <%=h u.label :first_name,'First Name' %> > <%=h u.text_field :first_name,:maxlength => 50 %> > > > Thanks in advance > Tom > -- > 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.
[Rails] Re: h() method in form partial
> My question is if I call this same partial in edit.html.erb also, > how can I apply the h() method like below (since this fields being > populated with value from db being an edit form) > > > <%=h u.label :first_name,'First Name' %> > <%=h u.text_field :first_name,:maxlength => 50 %> > > I'm pretty sure the text_field method will cover that for you - you wouldn't want to put the h where you have there or you'd end up escaping the actual field. If you really wanted to override the value then you could do something like this: <%= u.text_field :first_name, :value => h(your_value) %> -- 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: Ruby Manor: Manor Harder - videos now available
Any chance they are available for download somewhere? Seems like they are currently only playable with the embedded flash player. Sometimes nice to be able to watch these on the bus. On Mar 22, 3:10 am, comopasta Gr wrote: > Thanks! Already picked a couple that I'll be eating. > > Cheers. > -- > 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.
[Rails] Auto Trim w/ Erubis (Rails 3.0 beta)
Hey, I'm relatively new to Rails. (I was actually a Merb guy before) and I'm getting my feet wet with the beta. It doesn't appear that auto trim is enabled with Erubis by default. What's the "proper" way to enable this? -- 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] h() method in form partial
Hi I have a doubt. Dont know it is valid. Just asking. I am trying to reuse the same partial _form for both new and edit. So from new.html.erb I call partial like <%= render :partial => 'user_fields', :locals => {:f => f}%> and in _user_fields.html.erb an example field as <%= u.label :first_name,'First Name' %> <%= u.text_field :first_name,:maxlength => 50 %> My question is if I call this same partial in edit.html.erb also, how can I apply the h() method like below (since this fields being populated with value from db being an edit form) <%=h u.label :first_name,'First Name' %> <%=h u.text_field :first_name,:maxlength => 50 %> Thanks in advance 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] Re: NoMethodError in AdminController#index
Top link in google: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/39739e012b09f97a/7364aa0c8bf5050f Read the replies about scaffolding basically you'll need to install the scaffolding gem: >From a command prompt in your app root: ruby script/plugin install scaffolding or install a previous version of rails (if you are working through a book it's probably a good idea to use the same version it uses) gem install rails -v="1.2.3" For simplicities sake probably just uninstall your current rails version (gem uninstall rails) first then install the older version; that way you'll know the rails commands are running the correct version. 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: Java script errrrror in rails
> ActionView::TemplateError (Called id for nil, which would mistakenly be > 4 -- if you really wanted the id of nil, use object_id) on line #1 of > app/views/lists/import.js.rjs: > 1: id = dom_id(@list) Will need to see some code - however the simple answer from your error is that @list is nil. Perhaps you are missing a: @list = List.find(params[:id]) before this line 1? Kind Regards 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: How to reference a select_tag within a form
Hi Frederick, As I mentioned to Colin, I would start a new thread on this question, which is at http://groups.google.com/group/rubyonrails-talk/tree/browse_frm/thread/d0ca35d39de37478/cd6ed92bd974e311?rnum=1&_done=%2Fgroup%2Frubyonrails-talk%2Fbrowse_frm%2Fthread%2Fd0ca35d39de37478%3F#doc_cd6ed92bd974e311 Thanks for looking into my problem. But I just noticed that there is another response on this thread. > button_to_function creates a form, which would result in a form nested inside > a form, which isn't allowed. Wow. As I mentioned on the other thread, I posted code on that seemed clean from a Rails perspective and from an HTML perspective. So, if button_to_function is inappropriate for forms, can I specify an image that, when clicked, would toggle a page with the appropriate id specified? Is there an example on the web that you'd recommend? Best wishes, Richard BTW, my current code, with HTML generated and Validation results is at http://www.pastie.org/882256 On Mar 22, 7:00 pm, Frederick Cheung wrote: > On Mar 22, 9:18 pm, > RichardOnRails wrote: > > It brought up a list of vendor-names immediately under my Vendors > > textbox, which worked great as far as I was concerned. Then I tried > > to turn it into a real drop-down: > > 1. I added style="display:none" to the div so that the drop-down was > > hidden when the page opened > > 2. I added <%= button_to_function("ShowList", > > % ) %> following the text_field > > > Hiding the drop-down worked, but the button failed to restore it. > > Validating the resulting HTML revealed the a div is not permitted in > > the scope of a form. > > button_to_function creates a form, which would result in a form nested > inside a form, which isn't allowed. > > 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: How to initially hide a drop-down control and have an image control make it visible
Hi Hassan, please take a look at my reply to Michael. On Mar 22, 6:11 pm, Hassan Schroeder wrote: > On Mon, Mar 22, 2010 at 2:51 PM, RichardOnRails > > wrote: > > Thanks for joining the conversation. I ran my the HTML page which was > > generated by my .erb. I had a form_for with an embedded div and the > > HTML page had an embedded div. W3C didn't like it. The details are > > athttp://www.pastie.org/881730. > > Read line 11 of your validation pastie -- that is almost certainly your > problem. > > Getting used to reading the HTML DTD(s) would be a good idea :-) > > -- > 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.