Re: [Rails] authlogic and NameError "undefined local variable or method `login'"
On 2 April 2010 13:18, Marian Steinbach wrote: > Hi! > I am using authlogic and I have a User model (with act_as_authentic) > without the "login" field, since I use "email" as the user name. As it > says in the authlogic documentatation, that should be the way it works > when there is no login field. > > When I create new users manually via the User -> new form, everythings > works fine. > > But: > > Now I'd like to add user accounts as a side effect when anonymous > users fill in a form (actually it's the "new" form for an entity > called SearchSubscription). > > Now, in my SearchSubscription class, I have this "before_create > :assign_user" callback: > > def assign_user > if self.user_id.nil? > # find user with the given email address. If not present, create new > user. > user = User.find(:first, :conditions => {:email => self.email}) > if !user.nil? > self.user_id = user.id > else > # User not found, so create one > randompassword = > Base64.encode64(Digest::SHA1.digest("#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{login}"))[0..7] What is that login doing in the line above I wonder? I am not quite sure what the [0..7] is for either. > user = User.create(:email => self.email, :password => > randompassword, :location => self.location) > if user.id > self.user_id = user.id > else > flash[:warning] = "Could not create user account" > end > end > end > end > > This works well for email addresses that have a user entry. But > whenever I try to create a new SearchSubscription with an unknown > email address, I get the following error: > > NameError (undefined local variable or method `login' for > #): The clue is in the error message, it is SearchSubscription that it is complaining about, not User. Colin > app/models/search_subscription.rb:26:in `assign_user' > app/controllers/search_subscriptions_controller.rb:21:in `create' > > I have the impression that somewhere, the "User" class requires the > login. But I don't want to maintain a login field, since I want to use > the email address for that. > > Any ideas? > > Thanks! > > Marian > > -- > 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] Paperclip permission denied error
I am hoping someone could shed some light on this problem. I am setting up a new server to host a Rails app and it is almost done. The only error I'm getting is permission denied when the Paperclip plugin uploads the image and attempts to move it to its final location. It can upload to the temp folder without problem and execute the ImageMagick commands without a problem. It is the same folder structure as my old server Old server apache ran as "nobody". New server I am not sure. From what I can tell it runs under "daemon", but I've tried these permissions with no success: I've tried different ownerships and permissions on the folders: Ownership: nobody Ownership: daemon Ownership: root Folder/File permissions: 755 and 777 Nothing has allowed it to move the uploaded image to the final folder. I've been looking at this took long after a long hard fought battle with ImageMagick installation issues. Thanks for any insight, Chris -- 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 comments, belongs to post
I made a posts scaffold, and a comments scaffold Now i want to link the two of them together by -- Post-- has_many :comments and comments- belongs_to :post After that, I have no idea what to do in the controller or form for my comments What do i need to change in the comments controller and form so every comment that gets created is assigned to a post? Btw, i already have a post_id:integer column in my comments table I REALLY NEED HELP!! thanks a lot -- 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: App_Controller and partial issues with has_many through
So I put this in my controller: logger.debug "Person attributes hash: #...@user_interests.inspect}" And got this: Person attributes hash: [#, #] Shouldn't it be the interest.post info for each interest, not just the model attributes for the interest table? -- 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: Ruby-ldap timeout
Correction. SystemTimer works when binding, but *does not work* with the search / search2 method(s). If the LDAP server hangs for any reason, SystemTimer fails to kill the thread, and even though the Timeout::Error exception is thrown, it is only after much more time than what you define in the timeout_after(time) method. I've tried to contact Philippe, the author regarding this, let's see how it goes. Meanwhile, if anyone has a clue on why it is failing, please share! Cheers, Marcelo. On Thu, Apr 1, 2010 at 4:09 PM, Marcelo de Moraes Serpa wrote: > Hi Jeff, > > Thanks! Every single day I'm amazed by what's possible with Ruby, the more > I learn, the less I know, but I guess that's good :) > > This led me to the SystemTimer gem. The Timeout class was failing, I guess > because it is external call that "cross the barriers", as explained here: > http://ph7spot.com/musings/system-timer). SystemTimer works like a charm > ;) > > Cheers, > > Marcelo. > > > On Thu, Apr 1, 2010 at 1:21 PM, Jeff Lewis wrote: > >> Hi Marcelo, >> >> If that ldap lib doesn't include any timeout settings/params for >> timing out long-running ldap calls (which if you're talking about ruby- >> net-ldap, it doesn't at this time), then one way would be to wrap >> those potentially-long-running calls in ruby's timeout (http://ruby- >> doc.org/core/classes/Timeout.html) to at least force a timeout on your >> app's side of the process, something like: >> >> ... >> TIMEOUT_SECS = 10 # or whatever the max should be. >> >> ... >> timeout_status = nil >> begin >>timeout_status = Timeout::timeout(TIMEOUT_SECS) do >> # do stuff that might take too long >>end >> rescue Timeout::Error => te >># log it and ... >> end >> ... >> >> Jeff >> >> >> On Apr 1, 11:18 am, Marcelo de Moraes Serpa >> wrote: >> > Hello list, >> > >> > Does anyone know if ruby-ldap supports connection timeouts? We have LDAP >> > integrated into our authentication system to provide LDAP authentication >> as >> > well. It works fine if you input a valid host/port and if the LDAP >> server is >> > responding ok. However, if the host doesn't respond for some reason >> (could >> > be an invalid IP), ruby-ldap hangs there waiting forever, hanging the >> > application, something that obvisouly could cause potential problems >> (since >> > it uses passenger). >> > >> > Any ideas on how to handle that? >> > >> > Thanks, >> > >> > Marcelo. >> >> -- >> 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: Using Builders
Here is the builder file: xml = Builder::XmlMarkup.new xml.graph(:caption=>'Closing Ratios', :numberPrefix=>'', :formatNumberScale=>'0',:decimalPrecision=>'4') do for item in arr_data xml.set(:name=>item[0], :value=>item[1],:color=>''+get_FC_color) end 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 at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: App_Controller and partial issues with has_many through
When inspecting it I get [#,#,#,#] and my title reads "Your Interests (4)" and the print out is # # # # What is # all about? Is that an object filled with objects? Colin Law wrote: > On 2 April 2010 15:07, Jason Newport wrote: >> class ApplicationController < ActionController::Base >> �end >> � �<% @user_interests.each do |interest| -%> >> >> seems to be counting the number of posts on the specific pages (index or >> show) and totaling those up as a users interests. �And if for one user I >> add two interests and view the single post page then the title will read >> "You have 3 interests", thus counts the two interests I really am >> interested in plus the one for the Post page I am even though I have yet >> to click/select it as an interest. > > I would suggest installing ruby-debug, then you can break into the > controller or the view and inspect the variables and work out what is > going wrong. > > See the rails guide on debugging at http://guides.rubyonrails.org/ > > Colin -- 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 help with find
Finally figured out something that worked. @club = Club.find(params[:club_id]) ids = @club.members.connection.select_values('SELECT person_id FROM members') @people = Person.all(:order => 'name_sort', :conditions => ["id NOT IN (?)", ids]) Any comments or better methods. -- 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] GurusQ: Metal calling disparity-How to install metal in code
I have a simple class that I want to install as Rails Metal. I don't want to put it into a file in app/metal for reasons I don't want to go into. It looks like this, and handler is defined elsewhere. class UrlFilter ALLOW = [404] DENY = [403] def self.call(env) handler.call(env["PATH_INFO"]) ? ALLOW : DENY end end I've tried installing it like this : ActionController::Dispatcher.middleware.use UrlFilter but on the first request it crashes with : Sat Apr 03 00:29:43 +0800 2010: Read error: # /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:31:in `call' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:31:in `klass' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:42:in `active?' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in `active' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `find_all' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in `each' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in `find_all' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in `active' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:116:in `build' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:113:in `call' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' script/server:3 The rails calling code looks like this : def klass if @klass.respond_to?(:call) @klass.call elsif @klass.is_a?(Class) @klass else @klass.to_s.constantize end rescue NameError @klass end def active? return false unless klass if @conditional.respond_to?(:call) @conditional.call else @conditional end end Notice when calling call no arguments are passed (twice!) ? Every metal example I've seen defines the entry method as def self.call(env) yet this calling code doesn't pass any. Whats going on ? How do I define and install a metal class in code ? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Rails cascading delete
Thanks all. Destroy worked great!, Thanks Hila; On Apr 2, 2:41 am, Lasse Bunk wrote: > Hi Hilal, > > You need to use :dependent => :destroy instead of :delete_all because > :delete_all doesn't fire any callbacks. That's why it only deletes one > level. > > /Lasse > > 2010/4/2 Hilal > > > Hello There: > > I am trying to do a deep cascading deletes in rails. > > > The schema looks like this: > > > Blogs (has many) entries ( has many ) comments > > > A blog has n entries, an entry has n comments. > > > So, in my Blog model I use > > has_many :entries, :dependent => :delete_all > > and in my Entry model I use > > has_many :comments,:dependent => :delete_all > > > The problem I am having is that deleting blogs, will only delete > > entries, but will not delete comments. In other words, the cascading > > delete isn't deep? > > > Am I doing something wrong here? > > > Thanks > > Hilal > > > -- > > 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] Using Builders
I am using RoR 2.3, and have installed the builder gem I have a line in a view as follows: str_xml = render "fusioncharts/array_example/ss_array_data.builder", {:arr_data => @arr_data} Which does not set str_xml to anything. I can confirm that in my controller I have @arr_data set up and populated properly. (And in my controller, I have require 'builder' at the top) In my views folder, I have a folder set up under it as "fusioncharts/ array_example/" and the file ss_array_data.builder. (However, this may be why str_xml is not being set -- when I go to the URL which would invoke this view, I get "Missing template _ss_array_data.builder in view path..." It will only render the page if I put the underscore before the filename ss_array_data.builder, making it a partial). What am I not understanding about builders that I cannot convert my array @arr_data to str_xml ? Thanks so much, RVince -- 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: Best way of sorting/grouping objects
By any chance do you have a model named PageType? If you, you could set up a relationship between PageType and Page: page.rb: belongs_to :page_type page_type.rb: has_many :pages Then display it with: your_controller.rb: @page_types = PageType.all your_view.html.haml (or .erb, etc.) - @page_types.each do |page_type| %h1= page_type.name %ul = list_of page_type.pages do |page| = page.name If you don't already have a PageType model, or don't want to introduce another model, you could probably use: @page_types = Page.all(:order => 'page_type', :group => 'page_type') and then play around with the result of that. (At least I think that's correct… haha, sorry if it's not) Good luck, Angelo On Apr 2, 7:31 am, Brent wrote: > That could work. But I need it to order by page_order also. I would > like to group them into 3 groups then sort them by that. In the end I > want it to look something like this in html... > > TYPE ONE > Page 1 > Page 2 > > TYPE TWO > Page 1 > Page 2 > > Before I was doing something like this (I had an array of each page > type called page_types): > > <% page_types.each do |t| %> > <%= t %>'s > <% Page.find(:all, :conditions=>{:page_type=>t}, :order=>position > %> > etc. > <% end %> > <% 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 at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: "new" form as partial?
On Apr 2, 4:27 pm, Marian Steinbach wrote: > Creating a certain type of database record is a very frequent task in > my application (or at least it should be ;-)). So I want to be able to > place the form for creating that database record in practically any > view, not just the /mymodel/new view. I'm sure you can refactor code to fit almost anything into a single new/edit partial :) But in my small experience the models are different enough so that having different views for different models makes the code more readable. That said, I almost always share new and edit for a model in a partial: e.g. new.html.erb <%= render( :partial => "form", :locals => { :buttonname => 'Add' } ) %> edit.html.erb <%= render( :partial => "form", :locals => { :buttonname => 'Update' } ) %> _form.html.erb <%= error_message_on :lab, :base %> <% form_for ..., do |f| %> <%= f.submit buttonname %> ... <% end %> Ryan Bates has great screencasts on this sort of thing, and I found his Mastering Rails Forms http://www.pragprog.com/screencasts/v-rbforms/mastering-rails-forms ($5 a video) to be a great start. 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.
[Rails] Re: ScrAPI HTTPNoAccessError
I should also add - Before I got the findurl method to just strip out any URLs with non standard characters, I tried this line: fullurl.gsub!(",","%2C") Which replaced the commas with the URL friendlier code. This didn't work either, nor did putting the whole lot inside a CGI.escape("") The scrAPI documentation isn't particularly helpful in regards to what format the URL needs to be in. -- 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: Weird date/time incompatibility
On Apr 2, 6:05 pm, Craig White wrote: > they actually are in sync > > Fri Apr 2 17:13:05 CDT 2010 == 2010-04-02 22:13:05 (UTC) as CDT is UTC > + 5 hours Sorry for my sloppiness--I understand. I guess my main question is why would it show the correct time in the view on one machine, but not another? datetime.strftime("%A %B %d %Y %I:%M:%S %p") Is different for each machine. I'm busily writing code to detect where the user is, and adjusting the time shown in the view accordingly, but I'm still mildly confused by why the two views show differently. Thanks, 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.
[Rails] ScrAPI HTTPNoAccessError
Hi, I'm having some problems using scrAPI. I'm getting some HTTPNoAccessErrors on certain urls. The program searches a page (http://en.wikiquote.org/wiki/List_of_films) for all of the links on it that go to pages with movie quotes on them. It then loops through the list, pulling out the details from each page using this method: def self.scrapemovies Scraper::Base.parser :html_parser urlarray = Movie.findurls moviescraper = Scraper.define do process "h1", :name => :text process "p:nth-child(4)", :description => :text result :description, :name end urlarray.each do |url| fullurl = "http://en.wikiquote.org#{url}"; movieurl = URI.parse(fullurl) data = moviescraper.scrape(movieurl) movie = Movie.new movie.url = fullurl movie.name = data.name movie.description = data.description movie.save end end This worked ok until it got to http://en.wikiquote.org/wiki/20,000_Leagues_Under_the_Sea which gave me the http error because it had a comma in the URL. I wrote a little bit of code in the Movie.findurl method that just stripped out any URLs with commas or parentheses in as a bodge just to get things working, but I'm even getting the error on this URL: http://en.wikiquote.org/wiki/27_Dresses which is very odd, because it worked fine on the previous one which was : http://en.wikiquote.org/wiki/25th_Hour. I can't see the difference between them - I've tried manually visiting the page, and it's fine. I'm assuming that I need to do some sort of cleverer parsing on the URLs (so that I can include the ones with commas and parentheses too). Is the Scraper::Base.parser :html_parser line got anything to do with it? I couldn't get the Tidy plugin to work properly, but I'm not sure that it's got anything to do with the URL parsing anyway. I'm totally stuck - thanks in advance for any help. Jules. -- 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: Weird date/time incompatibility
On Fri, 2010-04-02 at 15:28 -0700, Dudebot wrote: > > On Apr 2, 3:12 pm, Colin Law wrote: > > > Am I right in assuming that is what is contained in the > in the html? If so then the first thing is that they are in different > > timezones. Can you confirm that you are definitely seeing the above > > dates with the same version of the code. You said you had been > > ... > > Do you want to see a local time there or UTC? > > Thanks again--the difference was that I had this in the development > config/enviroment.rb > config.time_zone = 'UTC' > But not in the production file. I uncommented it in the production > environment.rb just now, and lo and behold, that part is now working. > > Except--I now remember I had in commented out of the production server > as another part of the code which displays the "created at" field for > a record was giving the wrong time. E.g. if I run date in a terminal > > I get Fri Apr 2 17:13:05 CDT 2010 > > (Which is my time) > But for the created at for this record in the database I'm getting > > 2010-04-02 22:13:33 > > I don't seem to have that problem on my development machine (MacOS > laptop). The production server is a Redhat Linux machine. > > Any idea how to "sync" created at and the system time on the > production server? > > Again, many TIA, > Craig they actually are in sync Fri Apr 2 17:13:05 CDT 2010 == 2010-04-02 22:13:05 (UTC) as CDT is UTC + 5 hours 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.
[Rails] Re: HAS_MANY BELONGS_TO noobie question
bump... :) i really need help guys. On Apr 2, 12:39 pm, David Zhu wrote: > Oh, thanks that relaly helped, but one more thing- > > If i assigned posts to anotherposts, through a has_many :anotherposts > and belongs_to :posts relationship, how would i do @post = > current_user.posts.build(params[:post]) in this situation? Because i > dont have the current_user helper anymore, because we are not dealing > with users, but with the post that i want to create anotherposts ontop > of. > > so basically instead of the current_user helper, i want to use the > post that the anotherposts is being created on. > > Do you understand? Hit me with more questions if you want :) > > I really need help, this shouldn't be difficult at all. Just a minor > switch, that i can't get my mind around. Hope you can help! thanks!! > > On Mar 27, 10:26 am, Lasse Bunk wrote: > > > HeyDavid, > > > It's really pretty easy and straightforward. > > In your PostsController: > > > def create > > @post = current_user.posts.build(params[:post]) > > if @post.save > > # ... > > else > > # ... > > end > > end > > > Also in your PostsController, to list posts only from current_user: > > > def index > > @posts = current_user.posts > > end > > > If you want your show method to only look for posts from current_user: > > > def show > > @post = current_user.posts.find(params[:id]) > > end > > > /Lasse > > > 2010/3/27DavidZhu > > > > Hey, > > > > I made my authentication system using Authlogic, and I have a > > > current_user helper > > > > Now, I also made a scaffold called posts, and everytime a user creates > > > a post using that scaffold, i want it to be assigned to that > > > particular user. > > > > So i can render out the posts that ONLY that user made. > > > > Now, the question is what to do in the forms, and what to do in the > > > posts controller. > > > > Right now, I already have a has_many belongs_to relationship between > > > the too, but i dont know where to go next. What do i have to chnage in > > > the posts controller? What is my post form supposed to look like in > > > order for it to be associated with the current_user? > > > > AWww ive been trying to get my mind around this, but i can't. i need > > > help. really bad. > > > > Someone please help. please!! > > > > -- > > > 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: Rails model design visualization
On Apr 2, 3:49 pm, "Joe Smith" wrote: > In addition to railroads, The rubymine IDE has a visualization system. Uses > the (proreitary) yFiles Graph visualization library, so the images look a > little fancier, but the basic graphs are not too disimilar. Thanks, Joe! I'll have to check it out... Looks like us poor academics are given a break on the price :) 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.
[Rails] Re: Weird date/time incompatibility
On Apr 2, 3:12 pm, Colin Law wrote: > Am I right in assuming that is what is contained in the in the html? If so then the first thing is that they are in different > timezones. Can you confirm that you are definitely seeing the above > dates with the same version of the code. You said you had been ... > Do you want to see a local time there or UTC? Thanks again--the difference was that I had this in the development config/enviroment.rb config.time_zone = 'UTC' But not in the production file. I uncommented it in the production environment.rb just now, and lo and behold, that part is now working. Except--I now remember I had in commented out of the production server as another part of the code which displays the "created at" field for a record was giving the wrong time. E.g. if I run date in a terminal I get Fri Apr 2 17:13:05 CDT 2010 (Which is my time) But for the created at for this record in the database I'm getting 2010-04-02 22:13:33 I don't seem to have that problem on my development machine (MacOS laptop). The production server is a Redhat Linux machine. Any idea how to "sync" created at and the system time on the production server? Again, many 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.
[Rails] HELP!! Rake aborted! Can't modify frozen hash
Too bad even the trace doesn't say which hash is involved. Sorry this post is long: am trying to provide enough context to be meaningful. Occurs _intermittently_ when rake jobs:work is pulling a command out of delayed_jobs while my status observer is in the process of parsing a log file for detailed results of the previous delayed_job denizen. I have an observer class (in RAILS_ROOT/lib ) which listens for the events, makes a copy of them and calls the owner class ( in apps/models ) which then calls on the log parser (also in /lib) to do the actual work. (Should both of those classes, the observer and the parser be in app/models?) Am due to deliver this application in a few days and this is killing it (and me). Am using DirectoryWatcher to look for flag files that indicate the start and finish of the delayed_jobs. That is started at the end of environment.rb like this: require 'directory_watcher' $scriptStatusObserver = ScriptStatusObserver.new dirToWatch ="#{RAILS_ROOT}/tmp/flags" $directoryWatcher = DirectoryWatcher.new( dirToWatch ) $directoryWatcher.glob= "*.flg" $directoryWatcher.interval=(15) $directoryWatcher.add_observer( $scriptStatusObserver ) $directoryWatcher.persist=("#{RAILS_ROOT}/tmp/flags/dw_state.yml") $directoryWatcher.start at_exit { $directoryWatcher.stop } This code is outside of the run method (btw is that the best place or is inside the run better?) Here is the observer: require 'script_run' class ScriptStatusObserver def initialize @rcvdEvents = [] end def update( *events ) begin puts "#{__LINE__.to_s}: ScriptStatusObserver events: \n"+events.to_yaml cnt = 0 events.each do |e| if e.to_s.match(/^\s*added/) cnt = cnt + 1 @rcvdEvents << e end end ScriptRun.new.catch_up( @rcvdEvents ) if cnt > 0 @rcvdEvents.clear rescue puts $! end end end Here is ScriptRun (it attaches to an associative table built with has_many:through) #require 'observer' class ScriptRun < ActiveRecord::Base set_table_name "scripts_runs" belongs_to :script belongs_to :run def parse( result ) parser = LogParser.new parser.parse(result) end def catch_up( events ) events.each do |e| typ = e.type path = e.path thisMatch = path.match(/flags\/(\d+)_(\d+)_([\d\.]+)_(\w+)\.flg/) run_id= thisMatch[1] script_id = thisMatch[2] ts= thisMatch[3] status= thisMatch[4] if e.to_s.match(/^\s*added/) status_update( script_id, run_id, status, ts, path ) end end end def status_update( script_id, run_id, status, ts, path ) scriptrun = ScriptRun.find(:first, :conditions => [ "run_id = ? and script_id = ?", run_id.to_i, script_id.to_i ]) if scriptrun.kind_of?(ScriptRun) currStatus = scriptrun.status if not currStatus == 'completed' scriptrun.update_attribute(:status, status) if status == 'parse' flag= File.new(path) logSpec = flag.gets flag.close logName = File.basename(logSpec) logPath = logSpec.sub(logName, '') logName =~ /^(([\w_]+)_([\w]+)_(\d+))\.log$/ name = $1 basename = $2 runenv = $3 tsOrPid = $4 result = Result.new result.log_path = logPath result.basename = basename result.name = name result.script_id = script_id.to_i result.run_id= run_id.to_i if runenv == 'sit' runenv = 'SIT3348' end result.application_environment_id = ApplicationEnvironment.find(:first, :conditions => [ "nodename = ?", runenv]).id parse(result) if run_completed?( run_id ) myRun = Run.find(run_id.to_i) if myRun.kind_of?( Run ) myRun.update_attribute( :completed, Time.now.to_f ) end end end end else puts "#{__LINE__.to_s}: ScriptRun.status_update: ScriptRun not found for run #{run_id} script #{script_id} ts #{ts.to_s}" end File.delete(path) end def run_completed?( id ) scriptruns = ScriptRun.find(:all, :conditions => [ "run_id = ?", id.to_i] ) scriptruns.each do |sr| if not sr.status == 'completed' return false end end return true end end LogParser is too long even for this post but it reads the script log and pulls detailed information (counts and timings) out of the log and writes to a details table. It also tallies and calculates averages and rolls those up into summary tables for quicker access from the web pages. Here is the error trace: (don't ask why everything is under my Windows profile. It's a long story) Scanner running 1270239731.43 directory_watcher.notify_observers: #, #]> update:[#, #] rake aborted! can't modify frozen hash C:/Documents and Settings/p
[Rails] Re: Trying to create search filter persistence using SearchLogic
Patrick Shainin wrote: > > For example, to add a check box that limits the search to rows with a > certain condition, you could define a named scope in Model.rb like this: > > named_scope :my_condition, :conditions => "your sql condition here" > > Then in the view form, you would include: > <%= f.label :my_condition, "Check to apply my condition" %> > <%= f.check_box :my_condition %> I forgot that f.check_box adds a hidden field so even unchecked, the condition will trigger. One way to get around that is to use lambda in the named scope and adjust what condition gets included based on the check box value: named_scope :my_condition, lambda { |check| "1"==check ? {:conditions=> "your sql condition here"} : {}} -- 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] "new" form as partial?
Hi! I think I'm trying to accomplish something very common, but I can't find a way to do it. Creating a certain type of database record is a very frequent task in my application (or at least it should be ;-)). So I want to be able to place the form for creating that database record in practically any view, not just the /mymodel/new view. I figured that this might be done using a partial, but since I'm pretty new to rails, I don't get it one. Can anybody point me to a tutorial for this problem? I'm using rails 2.3.5. Thank you! Marian -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Rails model design visualization
>> Railroad does this (after a fashion) http://railroad.rubyforge.org/ > > So that rocks. When did the world get so ultra cool? *Many, many* > thanks. plus one from me! Thank you very much! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Rails model design visualization
>> Railroad does this (after a fashion) http://railroad.rubyforge.org/ > > So that rocks. When did the world get so ultra cool? *Many, many* > thanks. plus one from me! Thank you very much! -- 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: Two controllers with create using the same model
Thanks a lot Colin, First of all, I'm using Rails 2.3.5. and Ruby 1.8.7. The generated HTML looks like this: The option suggested by you: <% form_for :student, @student, :url => {:controller => 'beiratkozas', :action => "create" }, :html => { :method => :post, :id => "beiratkozok" } do |f| %> gives the very same result, so somehow the form_for assumes that controller is 'beiratkozas'. Maybe because the path is: Views/beiratkozas/ new.html.erb to the view that contains the form_for. And works, since I have: map.connect 'beiratkozok', :controller => 'beiratkozas', :action => 'new' map.connect 'hallgato/:id', :controller => 'beiratkozas', :action => 'show' map.connect 'beiratkozas', :controller => 'beiratkozas', :action => 'create' I know that map.resources :beiratkozas would be a more Rails like approach, but it's more human readable for Hungarians if I use meaningful Hungarian words. The html is added since I need the ID for CSS, and I wanted a meaningful word as ID, since it makes CSS easier to read. On the other hand :method => :post was added since I saw something like that somewhere, and it made sense, since I want to use the POST verb in this case. Right? Peter P.S.: What do you mean putting my comments inline with the previous post? I'm simply hitting reply. -- 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: Trying to create search filter persistence using SearchLogic
dburges wrote: > I have just set up a search form on my index using SearchLogic- it > works great. However, since there are several search parameters in the > form I want the results of the most recent search to remain in effect > until the user does a new search. I can't figure out how to do this! > I've tried a few things with global and session variables but just > can't get it working. > > Any advice would be greatly appreciated! The previous form values you want for re-initializing the form are passed into your controller method in the params object. If you have built your form around an object called @search like this: form_for @search do |f| you just need to initialize @search with the search values in params, in the controller method (perhaps Controller#index), like this: @search = Model.search(params[:search]) If you have fields that are not part of Model that you want to include in the search and have those initialized to, define a named_scope in Model, and use that named_scope in the form for @search. Then it will also be part of the params search values and get initialized along with the other, automatically generated named scopes that correspond to the model fields. For example, to add a check box that limits the search to rows with a certain condition, you could define a named scope in Model.rb like this: named_scope :my_condition, :conditions => "your sql condition here" Then in the view form, you would include: <%= f.label :my_condition, "Check to apply my condition" %> <%= f.check_box :my_condition %> -- 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] http://api.rubyonrails.org/ not working!!
On Fri, Apr 2, 2010 at 8:57 PM, rorguy wrote: > Not sure if anyone else has looked at it, but I have been seeing this > for about a week now. The link "Rails: Complete API" on Documentaion > page on http://rubyonrails.org/documentation is not working. It fails > with following error: > > Precondition Failed > The precondition on the request for the URL /index.php evaluated to > false. This happens sometimes in my place. Looks like it may be some country-level proxy in Spain or something according to some people. The site is up. -- 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: http://api.rubyonrails.org/ not working!!
On Apr 2, 9:55 pm, Greg Donald wrote: > On Fri, Apr 2, 2010 at 12:57 PM, rorguy wrote: > > Not sure if anyone else has looked at it, but I have been seeing this > > for about a week now. The link "Rails: Complete API" on Documentaion > > page onhttp://rubyonrails.org/documentationis not working. It fails > > with following error: > > > Precondition Failed > > The precondition on the request for the URL /index.php evaluated to > > false. > > Works for me. > And me. It's also worth noting that you can generate those docs from any rails app - just run rake doc:rails Fred > -- > Greg Donald > destiney.com | gregdonald.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: please help; form_for passes nil
On Apr 2, 6:23 pm, dirtbug wrote: > I have an update button that doesn't update. Watching the server > during the attempt, I see: > > Processing OrvesController#update (for 128.119.60.171 at 2010-04-02 > 13:13:29) [PUT] > Parameters: {"orf"=>nil, "commit"=>"Update", "id"=>"19544"} > > orf is my model I'm trying to update in the database. Why is it nil? > It's probably worth taking a look at the raw data posted by the browser - if it is malformed in some way that could be causing rails to parse it in a funny way. It probably doesn't help that your html is malformed (a td must be contained in a tr or similar, i'm pretty sure you can't stick a form in a table like that and the button_to will create a second form (ie you'll have a form nested in another form) Fred > The view for the page with the update button is called edit.html.erb > and contains: > > Editing orf > > <% form_for @orf do |f| %> > <%= f.error_messages %> > <%= h @orf.locus_tag %> > <%= f.text_field 'current_annotation', :size => 50 %> > <%= f.submit "Update" %> > <%= button_to "Undo last change", :action > => :undo_last_change, :id => @orf %> > <% end %> > > orf's attributes locus_tag and current_annotation are being correctly > displayed. > > Here's the update method: > > def update > @orf = Orf.find(params[:id]) > if @orf.update_attributes(params[:orf]) > flash[:notice] = 'Orf was successfully updated.' > redirect_to orf_path > else > flash[:notice] = 'Update failed.' > redirect_to orf_path > end > end > > routes.rb contains the line: > map.resources :orves > > No error message appears in the web browser. The update just doesn't > change anything. > > I'm running Rails 2.3.0. > > Any idea what I'm doing wrong? -- 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] http://api.rubyonrails.org/ not working!!
On Fri, Apr 2, 2010 at 12:57 PM, rorguy wrote: > Not sure if anyone else has looked at it, but I have been seeing this > for about a week now. The link "Rails: Complete API" on Documentaion > page on http://rubyonrails.org/documentation is not working. It fails > with following error: > > Precondition Failed > The precondition on the request for the URL /index.php evaluated to > false. Works for me. -- Greg Donald destiney.com | gregdonald.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] http://api.rubyonrails.org/ not working!!
Hi, Not sure if anyone else has looked at it, but I have been seeing this for about a week now. The link "Rails: Complete API" on Documentaion page on http://rubyonrails.org/documentation is not working. It fails with following error: Precondition Failed The precondition on the request for the URL /index.php evaluated to false. -- 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] please help; form_for passes nil
I have an update button that doesn't update. Watching the server during the attempt, I see: Processing OrvesController#update (for 128.119.60.171 at 2010-04-02 13:13:29) [PUT] Parameters: {"orf"=>nil, "commit"=>"Update", "id"=>"19544"} orf is my model I'm trying to update in the database. Why is it nil? The view for the page with the update button is called edit.html.erb and contains: Editing orf <% form_for @orf do |f| %> <%= f.error_messages %> <%= h @orf.locus_tag %> <%= f.text_field 'current_annotation', :size => 50 %> <%= f.submit "Update" %> <%= button_to "Undo last change", :action => :undo_last_change, :id => @orf %> <% end %> orf's attributes locus_tag and current_annotation are being correctly displayed. Here's the update method: def update @orf = Orf.find(params[:id]) if @orf.update_attributes(params[:orf]) flash[:notice] = 'Orf was successfully updated.' redirect_to orf_path else flash[:notice] = 'Update failed.' redirect_to orf_path end end routes.rb contains the line: map.resources :orves No error message appears in the web browser. The update just doesn't change anything. I'm running Rails 2.3.0. Any idea what I'm doing wrong? -- 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 and PHP app under the same domain
Hi! Depending on how much power you have over your server, I would recommend "pound" for that. But it does a little more than only what you want. And it requires that you change your complete virtual server configuration. http://www.apsis.ch/pound/ Regards, Marian On Fri, Apr 2, 2010 at 1:59 PM, Yiannis wrote: > Hello > > I have a rails site in a domain like http://domain.com/ which is in > one folder the whole application and a blog (wordpress - php > application in another folder) under http://blog.domain.com/. > > How can I do http://domain.com/blog/ shows up the php application? > > Thank 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.
[Rails] authlogic and NameError "undefined local variable or method `login'"
Hi! I am using authlogic and I have a User model (with act_as_authentic) without the "login" field, since I use "email" as the user name. As it says in the authlogic documentatation, that should be the way it works when there is no login field. When I create new users manually via the User -> new form, everythings works fine. But: Now I'd like to add user accounts as a side effect when anonymous users fill in a form (actually it's the "new" form for an entity called SearchSubscription). Now, in my SearchSubscription class, I have this "before_create :assign_user" callback: def assign_user if self.user_id.nil? # find user with the given email address. If not present, create new user. user = User.find(:first, :conditions => {:email => self.email}) if !user.nil? self.user_id = user.id else # User not found, so create one randompassword = Base64.encode64(Digest::SHA1.digest("#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{login}"))[0..7] user = User.create(:email => self.email, :password => randompassword, :location => self.location) if user.id self.user_id = user.id else flash[:warning] = "Could not create user account" end end end end This works well for email addresses that have a user entry. But whenever I try to create a new SearchSubscription with an unknown email address, I get the following error: NameError (undefined local variable or method `login' for #): app/models/search_subscription.rb:26:in `assign_user' app/controllers/search_subscriptions_controller.rb:21:in `create' I have the impression that somewhere, the "User" class requires the login. But I don't want to maintain a login field, since I want to use the email address for that. Any ideas? Thanks! Marian -- 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] Issue with libxml validation block
Hello, I have a weird issue with the ruby Libxml2 ruby bindings in a Rails project. I use the validate_schema method, with a block which should be called on each validation error. The problem is that this block is not always triggered : specifically, it works with the Webbrick server, but NOT with the console script, or the thin (which use rack) webserver... Of course I use exactly the same document and schema. I've tried development and production environments with no change ! Also another difference between Webbrick and Console/Thin, is with the error handler. With Console/Thin, &LibXML::XML::Error::VERBOSE_HANDLER is used, since the error is printed. However with webbrick nothing is outputted so either there is no handler, or it's QUIET_HANDLER If you need more details than that, please ask... Also if you feel it's not a Rails' problem, please tell me where I can go ! I tried to check how the gems are loaded in each case, to see any differences, but I couldn't figure out how it works ! In environment.rb config.gem "libxml-ruby", :lib => 'xml', :version => "=1.1.3" Archlinux : libxml2 2.7.7-1 Gem rails (2.3.5) thin (1.2.7) rubygems-update (1.3.6, 1.3.5) rack (1.1.0, 1.0.1) Regards, -- 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 model design visualization
"Dudebot" wrote in message news:f2c00b23-cb4a-4b09-9325-d2c64c3a4...@w17g2000yqj.googlegroups.com... I'm a fairly visual person, and I have a piece of paper with many boxes and arrows with labels like "has many" and "belongs to" for my database models. It's messy, but it works. What I keep looking for--weeks, actually, I'm certain it's out there, but I haven't hit on the right set of Google query terms :)--is something that will take a Rails set of models and show its design. Does anyone know of such a thing? And if not, what are people using to visually lay out their model designs? In addition to railroads, The rubymine IDE has a visualization system. Uses the (proreitary) yFiles Graph visualization library, so the images look a little fancier, but the basic graphs are not too disimilar. One nice feature is that it is live unlike railroads, alowing you to move around the models if you did not like the default layout. It also lets you show/hide the special properties of a model like 'Created_at', as well as show or hide the user defined models. Probably not worth considering unless you already use the Rubymine IDE, but I thought it should be thrown out there. Now for an aside: I know IDE's are not particularly popular in the Rails community, and for good reason. Most IDEs are fairly bloated, and often make some tasks harder. Depite being a java-based IDE it is not as bloated as say an Eclipse-based IDE. The IDE though is suprising good at offering good options for autocomplete, although not perfect, but with a dynamically typed language perfect is just not possible. Unfortunately, in a few places the Rubymine IDE does make some tasks harder. An example is not being able to just type "rake db:migrate" but having to use a keystoke combination to open a dialog box to choose which version to migrate the database to. Perhaps a furtue version will offer a command prompt for those who like the code completion, refactoring helpers, and some of the other little nice touches an IDE can offer[1], but want to keep the existing command line workflows. I know the latest private beta of RadRails is offering 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.
Re: [Rails] Re: Two controllers with create using the same model
On 2 April 2010 21:21, WSzP wrote: > Thanks a lot Colin, that was my problem. > > From documentation I managed to make a working form_for: > > <% form_for :student, @student, :url => { :action => "create" }, :html > => { :method => :post, :id => "beiratkozok" } do |f| %> > > This works, but I don't understand why do I need the :student in the > front. What does it do? It is in the docs, the :student says that the object being displayed and submitted is of type student, the @student is the variable containing the student. In fact since these are the same word you do not need both, either :student or @student will work I think, though using @student is more usual I think. Having both allows the class name and variable to be different. I don't know why you have the html options they should not be needed. I also don't understand why this is going to the beiratkozas controller, I would have expected it to go to the students controller. I would have expected you to put :url => { :controller => 'beiratkozas', :action => "create" } to send it to that controller. Check the html of the page (View, Page Source or similar in browser). By the way it may be a good idea to put your comments inline with the previous posts as it is then easier to follow the thread. Colin > > On Apr 2, 11:18 pm, Colin Law wrote: >> On 2 April 2010 21:00, WSzP wrote: >> >> > You got me wrong. I can't put the create method in the student >> > controller. >> > The question if, how could I use the create method from the >> > BeiratkozasController class, while the model is NOT Beiratkozas, but >> > Student. >> >> Have a look at the docs for form_for, you will see it has a url >> parameter which will allow you to specify the controller and action >> that you wish to be performed on the submit. >> >> 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: Two controllers with create using the same model
Thanks a lot Colin, that was my problem. >From documentation I managed to make a working form_for: <% form_for :student, @student, :url => { :action => "create" }, :html => { :method => :post, :id => "beiratkozok" } do |f| %> This works, but I don't understand why do I need the :student in the front. What does it do? On Apr 2, 11:18 pm, Colin Law wrote: > On 2 April 2010 21:00, WSzP wrote: > > > You got me wrong. I can't put the create method in the student > > controller. > > The question if, how could I use the create method from the > > BeiratkozasController class, while the model is NOT Beiratkozas, but > > Student. > > Have a look at the docs for form_for, you will see it has a url > parameter which will allow you to specify the controller and action > that you wish to be performed on the submit. > > 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: Two controllers with create using the same model
On Apr 2, 3:45 pm, DmitryPush wrote: > so now we can see exactly what rails told you - it is now create > method in student controller. :) > and why you view requesting student controller i already told you. > :) > > On Apr 2, 4:39 pm, WSzP wrote: > > > Hello, > > Thanks a lot, and here is my students_controller.rb:http://pastie.org/900218 > > So I had one, but forgot to paste it to pastie. > > 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.
Re: [Rails] Re: Two controllers with create using the same model
On 2 April 2010 21:00, WSzP wrote: > You got me wrong. I can't put the create method in the student > controller. > The question if, how could I use the create method from the > BeiratkozasController class, while the model is NOT Beiratkozas, but > Student. Have a look at the docs for form_for, you will see it has a url parameter which will allow you to specify the controller and action that you wish to be performed on the submit. 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: Weird date/time incompatibility
On 2 April 2010 20:42, Dudebot wrote: > > > On Apr 2, 6:30 am, Colin Law wrote: > >> You say the html is correct in the index view so it cannot be an issue >> passing the dates to the index view, or you would see the wrong dates >> there. > > Thanks for helping with this. What I see in the development html is ? > date=2010-03-31+18%3A19%3A00+UTC > and what I see in the production html is ?date=Thu+Apr > +01+23%3A02%3A00+-0500+2010 > and I'm wondering if somehow it's choking on the date format on the > production server... Am I right in assuming that is what is contained in the http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Two controllers with create using the same model
You got me wrong. I can't put the create method in the student controller. The question if, how could I use the create method from the BeiratkozasController class, while the model is NOT Beiratkozas, but Student. WSZP -- 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: Two controllers with create using the same model
You got me wrong. I can't put the create method in the student controller. The question if, how could I use the create method from the BeiratkozasController class, while the model is NOT Beiratkozas, but Student. WSZP -- 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: Accessing models in "mounted" Rails 3 app
I think I just realized why this is happening. The container app is just a sample for testing out the mounted app, and I named it "Shop". I imagine there's some kind of conflict going on between the Shop defined in application.rb and the Shop defined in the model. Gonna go test this now, but I think that pretty much solves this mystery. On Apr 2, 9:33 am, Angelo Ashmore wrote: > Okay, it looks like Rails is pulling an April Fools on me. It like 18 > of the 19 models are accessible. I tried to list all the models using: > > ActiveRecord::Base.send(:subclasses).each { |model| puts model.name } > > and it only returned three of the models. Accessing all the models > directly (typing "Image" in the console, for example) accesses them > correctly. > > My Shop model, however, is still causing problems. Shop is definitely > accessible in the mounted app, but acts as if it does not exist in the > container app. > > Angelo > > On Apr 1, 3:11 pm, Angelo Ashmore wrote: > > > > > This is the first time I'm working with Engine's in Rails, let alone > > in Rails 3. I basically followed these steps to set up the mountable > > app:http://blog.dynamic50.com/index.php/2010/02/rails-3-0-mount-multiple-... > > > Now that the mountable app is built, I'm moving on to create the > > container app. In doing so, however, I am having trouble accessing the > > models in the mounted app. > > > Shop is a model I have the the mounted app, and when I try to access > > it in the container app, this is returned: > > > >> Shop.first > > > => NoMethodError: undefined method `first' for Shop:Module > > > Strangely enough, however, 3 of the mounted app's 19 models are > > accessible in the container app. Shop.class.name returns "Module" > > while Employee.class.name returns "Class" (Employee is a working model > > in the container app). > > > I'm quite lost on this. Any help is greatly appreciated! > > > Thanks, > > Angelo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Weird date/time incompatibility
On Apr 2, 6:30 am, Colin Law wrote: > You say the html is correct in the index view so it cannot be an issue > passing the dates to the index view, or you would see the wrong dates > there. Thanks for helping with this. What I see in the development html is ? date=2010-03-31+18%3A19%3A00+UTC and what I see in the production html is ?date=Thu+Apr +01+23%3A02%3A00+-0500+2010 and I'm wondering if somehow it's choking on the date format on the production server... -- 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: Accessing models in "mounted" Rails 3 app
Okay, it looks like Rails is pulling an April Fools on me. It like 18 of the 19 models are accessible. I tried to list all the models using: ActiveRecord::Base.send(:subclasses).each { |model| puts model.name } and it only returned three of the models. Accessing all the models directly (typing "Image" in the console, for example) accesses them correctly. My Shop model, however, is still causing problems. Shop is definitely accessible in the mounted app, but acts as if it does not exist in the container app. Angelo On Apr 1, 3:11 pm, Angelo Ashmore wrote: > This is the first time I'm working with Engine's in Rails, let alone > in Rails 3. I basically followed these steps to set up the mountable > app:http://blog.dynamic50.com/index.php/2010/02/rails-3-0-mount-multiple-... > > Now that the mountable app is built, I'm moving on to create the > container app. In doing so, however, I am having trouble accessing the > models in the mounted app. > > Shop is a model I have the the mounted app, and when I try to access > it in the container app, this is returned: > > >> Shop.first > > => NoMethodError: undefined method `first' for Shop:Module > > Strangely enough, however, 3 of the mounted app's 19 models are > accessible in the container app. Shop.class.name returns "Module" > while Employee.class.name returns "Class" (Employee is a working model > in the container app). > > I'm quite lost on this. Any help is greatly appreciated! > > Thanks, > Angelo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Is it possible to have a form without a submit tag in rails?
There may be chance of form without submit button .. In your example might be form is submitting in script by using the javascript function submit() inside the script tag, when any of the field changed inside the form $("#student_name").change(function(){ $("#sree").submit() }) <%=text_field 'student','name'%> Pito Salas wrote: > This is probably a stupid question but I am confused... > > I see an example in the 3d Edition of Agile Dev with Rails (page 539) > where a simple calculator view, with two text boxes for numbers and a > dropdown for what operation to perform, does not mention a submit button > or gesture. > > I don't understand that. Yes, the form_tag does indicate an :action => , > but what triggers that if there is no <%= submit_tag 'Save' %>? > > Thanks! > > Pito -- 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: Best way of sorting/grouping objects
That could work. But I need it to order by page_order also. I would like to group them into 3 groups then sort them by that. In the end I want it to look something like this in html... TYPE ONE Page 1 Page 2 TYPE TWO Page 1 Page 2 Before I was doing something like this (I had an array of each page type called page_types): <% page_types.each do |t| %> <%= t %>'s <% Page.find(:all, :conditions=>{:page_type=>t}, :order=>position %> etc. <% end %> <% 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 at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Issue with character encoding in http request
On Apr 2, 4:23 pm, Christophe Decaux wrote: > > By the way, I cannot ask the request sender to change his encoding method... > On the other hand, I've setup everything in my app to use utf-8 which works > fine... > Well if you cannot change the sender then you don't have a choice - you'll have to convert the input (probably an iso latin varient) into utf8. The iconv library can handle a large number of encodings. Fred > Thanks in advance, > > Christophe -- 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] Is it possible to have a form without a submit tag in rails?
This is probably a stupid question but I am confused... I see an example in the 3d Edition of Agile Dev with Rails (page 539) where a simple calculator view, with two text boxes for numbers and a dropdown for what operation to perform, does not mention a submit button or gesture. I don't understand that. Yes, the form_tag does indicate an :action => , but what triggers that if there is no <%= submit_tag 'Save' %>? Browser dependent, but usually if you hit ENTER while in a text field it will submit the form. Or perhaps that form's submission is being triggered via javascript. -- 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: HAS_MANY BELONGS_TO noobie question
Oh, thanks that relaly helped, but one more thing- If i assigned posts to anotherposts, through a has_many :anotherposts and belongs_to :posts relationship, how would i do @post = current_user.posts.build(params[:post]) in this situation? Because i dont have the current_user helper anymore, because we are not dealing with users, but with the post that i want to create anotherposts ontop of. so basically instead of the current_user helper, i want to use the post that the anotherposts is being created on. Do you understand? Hit me with more questions if you want :) I really need help, this shouldn't be difficult at all. Just a minor switch, that i can't get my mind around. Hope you can help! thanks!! On Mar 27, 10:26 am, Lasse Bunk wrote: > Hey David, > > It's really pretty easy and straightforward. > In your PostsController: > > def create > @post = current_user.posts.build(params[:post]) > if @post.save > # ... > else > # ... > end > end > > Also in your PostsController, to list posts only from current_user: > > def index > @posts = current_user.posts > end > > If you want your show method to only look for posts from current_user: > > def show > @post = current_user.posts.find(params[:id]) > end > > /Lasse > > 2010/3/27 David Zhu > > > Hey, > > > I made my authentication system using Authlogic, and I have a > > current_user helper > > > Now, I also made a scaffold called posts, and everytime a user creates > > a post using that scaffold, i want it to be assigned to that > > particular user. > > > So i can render out the posts that ONLY that user made. > > > Now, the question is what to do in the forms, and what to do in the > > posts controller. > > > Right now, I already have a has_many belongs_to relationship between > > the too, but i dont know where to go next. What do i have to chnage in > > the posts controller? What is my post form supposed to look like in > > order for it to be associated with the current_user? > > > AWww ive been trying to get my mind around this, but i can't. i need > > help. really bad. > > > Someone please help. please!! > > > -- > > 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] Issue with character encoding in http request
Hi there, I have an issue with character encoding on http request that I need to handle in my rails apps. Here's an example of my log : Processing MessagesController#incoming (for 217.117.146.164 at 2010-04-02 16:08:27) [GET] Parameters: {"action"=>"incoming", "z"=>"Je suis un bon ?l?ve.", "alias"=>"33699425463", "controller"=>"messages"} ... some db processing... Rendering messages/incoming Completed in 39ms (View: 2, DB: 27) | 200 OK [http://server.mydomain.com/in/?z=Je+suis+un+bon+%E9l%E8ve.&alias=33699425463] As you can guess I expect the system to receive the z value decoded as "Je suis un bon élève." and not "Je suis un bon ?l?ve." Anyone as faced this issue already ? By the way, I cannot ask the request sender to change his encoding method... On the other hand, I've setup everything in my app to use utf-8 which works fine... Thanks in advance, Christophe -- 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: Intermediate level tutorials
Thanks for the replies. I'll give both the books a read. My gaps do seem to be as much Web related as Rails. Ian -- 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] Is it possible to have a form without a submit tag in rails?
This is probably a stupid question but I am confused... I see an example in the 3d Edition of Agile Dev with Rails (page 539) where a simple calculator view, with two text boxes for numbers and a dropdown for what operation to perform, does not mention a submit button or gesture. I don't understand that. Yes, the form_tag does indicate an :action => , but what triggers that if there is no <%= submit_tag 'Save' %>? Thanks! Pito -- 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] App_Controller and partial issues with has_many through
On 2 April 2010 15:07, Jason Newport wrote: > I have a User model, a Post model, and an Interest model: > User has_many posts through interests > User has_many interests, dependent destroy > Post has_many users through interests > has_many interests, dependent destroy > Post has_many interests > Interest belongs to Post > Interest belongs to User > > Application_Controller is as follows: > class ApplicationController < ActionController::Base > before_filter :login_from_cookie > before_filter :find_user_interests > helper :all # include all helpers, all the time > session :session_key => '_blah_session' > > include AuthenticatedSystem > > def find_user_interests > �...@user_interests = current_user ? current_user.interests : [] > true > end > > end > > Application.html.erb has as follows: > <%= render :partial => "users/interests", :object => @user_interests %> > > _interests.html.erb partial is as follows: > > ul > <% unless current_user.nil? then -%> > <% @user_interests.each do |interest| -%> > li<%= interest.post.title %>/li > <% end %> > <% end -%> > /ul > > Given all this when I at localhost:3000/posts/1 my partial shows up > fine, but when in localhost:3000/posts I get an error undefined method > 'title' for nil:NilClass thus an error in the line li<%= > interest.post.title %>/li shown above in the _interests.html.erb > partial. > > What the heck would be the issue? > > Also what is weird, if I take out the code in the partial that dislays > the title, so to get around this error, I have another issue. I have a > title in the partial that is set like "You have @user_interests.length > interests" and when I am on the posts page and say the posts page has 10 > posts my title reads like "You have 10 interests" so its counting all > posts as an interest, even if the user hasn't selected the post as an > interest. And when I go to one specific Posts page, on that single Post > page, the above referenced title reads "You have 1 interests" so its > seems to be counting the number of posts on the specific pages (index or > show) and totaling those up as a users interests. And if for one user I > add two interests and view the single post page then the title will read > "You have 3 interests", thus counts the two interests I really am > interested in plus the one for the Post page I am even though I have yet > to click/select it as an interest. I would suggest installing ruby-debug, then you can break into the controller or the view and inspect the variables and work out what is going wrong. See the rails guide on debugging at http://guides.rubyonrails.org/ 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] Need help with find
Kind of new at this and have been unable to find an example of what I want to do. I have three models, people, clubs and members. @members = @club.members.all --> finds all club members How do I write a find of all people that are not members of @club 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] App_Controller and partial issues with has_many through
I have a User model, a Post model, and an Interest model: User has_many posts through interests User has_many interests, dependent destroy Post has_many users through interests has_many interests, dependent destroy Post has_many interests Interest belongs to Post Interest belongs to User Application_Controller is as follows: class ApplicationController < ActionController::Base before_filter :login_from_cookie before_filter :find_user_interests helper :all # include all helpers, all the time session :session_key => '_blah_session' include AuthenticatedSystem def find_user_interests @user_interests = current_user ? current_user.interests : [] true end end Application.html.erb has as follows: <%= render :partial => "users/interests", :object => @user_interests %> _interests.html.erb partial is as follows: ul <% unless current_user.nil? then -%> <% @user_interests.each do |interest| -%> li<%= interest.post.title %>/li <% end %> <% end -%> /ul Given all this when I at localhost:3000/posts/1 my partial shows up fine, but when in localhost:3000/posts I get an error undefined method 'title' for nil:NilClass thus an error in the line li<%= interest.post.title %>/li shown above in the _interests.html.erb partial. What the heck would be the issue? Also what is weird, if I take out the code in the partial that dislays the title, so to get around this error, I have another issue. I have a title in the partial that is set like "You have @user_interests.length interests" and when I am on the posts page and say the posts page has 10 posts my title reads like "You have 10 interests" so its counting all posts as an interest, even if the user hasn't selected the post as an interest. And when I go to one specific Posts page, on that single Post page, the above referenced title reads "You have 1 interests" so its seems to be counting the number of posts on the specific pages (index or show) and totaling those up as a users interests. And if for one user I add two interests and view the single post page then the title will read "You have 3 interests", thus counts the two interests I really am interested in plus the one for the Post page I am even though I have yet to click/select it as an interest. TIA -- 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: Superclass mismatch with Rails 3
On Fri, Apr 2, 2010 at 8:02 AM, Phil Ostler wrote: > Indeed you are right, changing the name of my application has fixed > this. Thank you! > > Reason for me naming it Rails is because I have separate folders in my > project development for different elements (e.g. Rails, Database Schema, > Flex) and it always worked in Rails 2 fine for me this way. > > I've used rails3b before but was mix and matching gem versions to try > and get around this problem. > > Now running Ruby 1.9.1-p378-rc2 with Rails 3.0.0.beta2! >From what I've read 1.9.1 is NOT recommended for use with Rails3 beta 2, they want us to use the latest pre-release version of 1.9.2 instead. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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 and PHP app under the same domain
On Fri, Apr 2, 2010 at 7:59 AM, Yiannis wrote: > Hello > > I have a rails site in a domain like http://domain.com/ which is in > one folder the whole application and a blog (wordpress - php > application in another folder) under http://blog.domain.com/. > > How can I do http://domain.com/blog/ shows up the php application? You could have rails redirect from domain.com/blog to blog.domain.com But it might be better to do this at the http server layer. For example if you are using apache as the front end, you could use mod_rewrite to route blog urls the the blog before the rails app ever sees them. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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] Ruport - table data to []
Anyone on here know how to access the data used in a Ruport table and return it as an Array [] ? Thank 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.
[Rails] Re: Two controllers with create using the same model
so now we can see exactly what rails told you - it is now create method in student controller. :) and why you view requesting student controller i already told you. :) On Apr 2, 4:39 pm, WSzP wrote: > Hello, > Thanks a lot, and here is my students_controller.rb:http://pastie.org/900218 > So I had one, but forgot to paste it to pastie. > 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] Re: Two controllers with create using the same model
Hello, Thanks a lot, and here is my students_controller.rb: http://pastie.org/900218 So I had one, but forgot to paste it to pastie. 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] Re: Two controllers with create using the same model
In addition, it happens because you using <% form_for(@student) do | f| %> helper if you look in HTML code (this helper appears to) you can find that request will be send to student controller... On Apr 2, 4:15 pm, DmitryPush wrote: > in your link I can see: > beiratkozas_controller.rb > subscriptions_controller.rb > > but where is students_controller.rb (StudentsController) ? > > Dose ruby asking you the same question?:) > > On Apr 2, 4:04 pm, WSzP wrote: > > > Any ideas? I still can't find out why this does not work, or how to > > solve. Or you guys prefer pasting code into the email instead > > ofhttp://pastie.org/899454? > > Thanks a lot. And Happy Easter! -- 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: Two controllers with create using the same model
in your link I can see: beiratkozas_controller.rb subscriptions_controller.rb but where is students_controller.rb (StudentsController) ? Dose ruby asking you the same question?:) On Apr 2, 4:04 pm, WSzP wrote: > Any ideas? I still can't find out why this does not work, or how to > solve. Or you guys prefer pasting code into the email instead > ofhttp://pastie.org/899454? > Thanks a lot. And Happy Easter! -- 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: Two controllers with create using the same model
Any ideas? I still can't find out why this does not work, or how to solve. Or you guys prefer pasting code into the email instead of http://pastie.org/899454 ? Thanks a lot. And Happy Easter! -- 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: Superclass mismatch with Rails 3
Indeed you are right, changing the name of my application has fixed this. Thank you! Reason for me naming it Rails is because I have separate folders in my project development for different elements (e.g. Rails, Database Schema, Flex) and it always worked in Rails 2 fine for me this way. I've used rails3b before but was mix and matching gem versions to try and get around this problem. Now running Ruby 1.9.1-p378-rc2 with Rails 3.0.0.beta2! Next stop, JRuby 1.5.0 dev snapshot... 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.
[Rails] Rails and PHP app under the same domain
Hello I have a rails site in a domain like http://domain.com/ which is in one folder the whole application and a blog (wordpress - php application in another folder) under http://blog.domain.com/. How can I do http://domain.com/blog/ shows up the php application? Thank 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: Weird date/time incompatibility
On 2 April 2010 12:16, Dudebot wrote: > On Apr 2, 2:22 am, Colin Law wrote: > ... > > Checking the html, the database entries with phpMyAdmin, and the log > file were where I went first--I should have written that. It's all > there, just like the development environment. The log file was what > pointed me to the database call, and I mocked it up with a script/ > console call that mimicked the one in my model. That's when I > discovered that it looks like the date format isn't being passed > correctly in the params hash, which I find really weird. It is, after > all, coming from the database originally. If the html is correct then it must be getting it out of the db ok so it is not a problem there. Yet you say the params are getting passed incorrectly from that html? is that in the log file you see that or after you get into the action? So what params are you seeing there in development and what in production? > > I think it may be how I pass the dates to the index view, as an array, > is where the formatting may change You say the html is correct in the index view so it cannot be an issue passing the dates to the index view, or you would see the wrong dates there. Colin > > labs = Lab.all( :conditions => [ "patient_id = ?", id ], :order => > "drawn DESC" ) > @dates = [] > labs.each { |lab| @dates << lab.drawn } > > But I could be wrong about that. > > Has anyone ever experienced a problem with date formatting like this? > And if so, how did you fix it? > > Another question for you gurus is, when I put a raise ---.to_yaml in > the production server code, those only appear in the logs, the > "errors" are prettily concealed on the production views. Any way to > temporarily shut that behavior off while I'm debugging the production > code? > > Again, many 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. > > -- 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: Weird date/time incompatibility
On Apr 2, 2:22 am, Colin Law wrote: ... Checking the html, the database entries with phpMyAdmin, and the log file were where I went first--I should have written that. It's all there, just like the development environment. The log file was what pointed me to the database call, and I mocked it up with a script/ console call that mimicked the one in my model. That's when I discovered that it looks like the date format isn't being passed correctly in the params hash, which I find really weird. It is, after all, coming from the database originally. I think it may be how I pass the dates to the index view, as an array, is where the formatting may change labs = Lab.all( :conditions => [ "patient_id = ?", id ], :order => "drawn DESC" ) @dates = [] labs.each { |lab| @dates << lab.drawn } But I could be wrong about that. Has anyone ever experienced a problem with date formatting like this? And if so, how did you fix it? Another question for you gurus is, when I put a raise ---.to_yaml in the production server code, those only appear in the logs, the "errors" are prettily concealed on the production views. Any way to temporarily shut that behavior off while I'm debugging the production code? Again, many 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: rss feed
You can do this with routing – in config/routes.rb: map.rss '/feeds/articles', :controller => 'articles', :action => 'index', :format => 'rss' /Lasse 2010/4/2 Rahul Mehta > hii lasse > > i have read this article but how to place rss feed to folder.. > thanks for reply.. > > > > On Apr 2, 3:25 pm, Lasse Bunk wrote: > > http://paulsturgess.co.uk/articles/show/13-creating-an-rss-feed-in-ru... > > > > 2010/4/2 Rahul Mehta > > > > > its not giving useful result dear .. > > > > > On Apr 2, 2:47 pm, Lasse Bunk wrote: > > > > Rahul, > > > > > > Tryhttp://www.google.com/search?q=rails+rss+feed > > > > > > /Lasse > > > > > > 2010/4/2 Rahul Mehta > > > > > > > hi all, > > > > > > > for my project need to generate rss feed and place in folder what > to > > > > > do ? > > > > > > > we need to have RSS feed generated and placed inside /feeds folder. > > > > > Format of these feeds should be valid RSS feed format. These feed > > > > > should contain whatever information is present in the field or > > > > > everything in the database table field. Number of entries in the > feed > > > > > should be limited to most recent five articles. > > > > > Please ensure that generated feed is the valid RSS feed. > > > > > > > what thing to use to put rss feed in the folder > > > > > i know how to generate rss feed generate by > > > > > href="url/ > > > > > to/rss/file" /> > > > > > > > but to put in the folder what to do i dont know > > > > > > > please help. > > > > > > > thanks > > > > > > > rahul > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "Ruby on Rails: Talk" group. > > > > > To post to this group, send email to > rubyonrails-talk@googlegroups.com > > > . > > > > > To unsubscribe from this group, send email to > > > > > rubyonrails-talk+unsubscr...@googlegroups.com > > > > > > > > > > > > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscr...@googlegroups.com > > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Form Authenticity Token Error generated from iframe
Hi, Iam trying to link my app from another site. I have used iframes and a form is being loaded in the iframe embeded in another site outside my rails app. So when the user submits this form it should effectively take me to the application site with the post data... iam getting authenticity token error while doing this.. can anyone guide me how to achieve the objective... thnks Nisha -- 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: rss feed
hii lasse i have read this article but how to place rss feed to folder.. thanks for reply.. On Apr 2, 3:25 pm, Lasse Bunk wrote: > http://paulsturgess.co.uk/articles/show/13-creating-an-rss-feed-in-ru... > > 2010/4/2 Rahul Mehta > > > its not giving useful result dear .. > > > On Apr 2, 2:47 pm, Lasse Bunk wrote: > > > Rahul, > > > > Tryhttp://www.google.com/search?q=rails+rss+feed > > > > /Lasse > > > > 2010/4/2 Rahul Mehta > > > > > hi all, > > > > > for my project need to generate rss feed and place in folder what to > > > > do ? > > > > > we need to have RSS feed generated and placed inside /feeds folder. > > > > Format of these feeds should be valid RSS feed format. These feed > > > > should contain whatever information is present in the field or > > > > everything in the database table field. Number of entries in the feed > > > > should be limited to most recent five articles. > > > > Please ensure that generated feed is the valid RSS feed. > > > > > what thing to use to put rss feed in the folder > > > > i know how to generate rss feed generate by > > > > > > > > > but to put in the folder what to do i dont know > > > > > please help. > > > > > thanks > > > > > rahul > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Ruby on Rails: Talk" group. > > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > > . > > > > To unsubscribe from this group, send email to > > > > rubyonrails-talk+unsubscr...@googlegroups.com > > > > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: rss feed
http://paulsturgess.co.uk/articles/show/13-creating-an-rss-feed-in-ruby-on-rails 2010/4/2 Rahul Mehta > its not giving useful result dear .. > > On Apr 2, 2:47 pm, Lasse Bunk wrote: > > Rahul, > > > > Tryhttp://www.google.com/search?q=rails+rss+feed > > > > /Lasse > > > > 2010/4/2 Rahul Mehta > > > > > hi all, > > > > > for my project need to generate rss feed and place in folder what to > > > do ? > > > > > we need to have RSS feed generated and placed inside /feeds folder. > > > Format of these feeds should be valid RSS feed format. These feed > > > should contain whatever information is present in the field or > > > everything in the database table field. Number of entries in the feed > > > should be limited to most recent five articles. > > > Please ensure that generated feed is the valid RSS feed. > > > > > what thing to use to put rss feed in the folder > > > i know how to generate rss feed generate by > > > > > > > > but to put in the folder what to do i dont know > > > > > please help. > > > > > thanks > > > > > rahul > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk@googlegroups.com > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscr...@googlegroups.com > > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: rss feed
its not giving useful result dear .. On Apr 2, 2:47 pm, Lasse Bunk wrote: > Rahul, > > Tryhttp://www.google.com/search?q=rails+rss+feed > > /Lasse > > 2010/4/2 Rahul Mehta > > > hi all, > > > for my project need to generate rss feed and place in folder what to > > do ? > > > we need to have RSS feed generated and placed inside /feeds folder. > > Format of these feeds should be valid RSS feed format. These feed > > should contain whatever information is present in the field or > > everything in the database table field. Number of entries in the feed > > should be limited to most recent five articles. > > Please ensure that generated feed is the valid RSS feed. > > > what thing to use to put rss feed in the folder > > i know how to generate rss feed generate by > > > > > but to put in the folder what to do i dont know > > > please help. > > > thanks > > > rahul > > > -- > > 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] [RAILS 3] 2 sup app in 1 app
Hi, I'm building an app which will become quite big (I hope ;-) ) and so I want to separate admin part and customers part. By separate, I mean not 2 namespaces (=1 app), but really 2 app (so I can shutdown customers and keep admin access for example). But, because the logic/model is the same, and some conf too, I would like to keep it in one directory (a rails 3 app folder). In rails 3, the app is a rack app, we have : -- module class Application < Rails::Application ... -- So I was thinking of doing 2 app like this inside my application.rb --- module XXXCustomers class Application < Rails::Application ... module XXXAdmin class Application < Rails::Application ... --- I could define the path for controllers and views {controllers,views}/admin — {controllers,views}/customers My questions/problems are - when I start the server how to tell it to start the admin app or the customers app. Maybe a rake parameter ? - is there other people who had try to do this - would you recommend me to use a different manner. For ex : share only the model between 2 "real" app - any other suggestions Thanks --- Nicolas -- 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] rss feed
Rahul, Try http://www.google.com/search?q=rails+rss+feed /Lasse 2010/4/2 Rahul Mehta > hi all, > > for my project need to generate rss feed and place in folder what to > do ? > > we need to have RSS feed generated and placed inside /feeds folder. > Format of these feeds should be valid RSS feed format. These feed > should contain whatever information is present in the field or > everything in the database table field. Number of entries in the feed > should be limited to most recent five articles. > Please ensure that generated feed is the valid RSS feed. > > what thing to use to put rss feed in the folder > i know how to generate rss feed generate by > > > but to put in the folder what to do i dont know > > please help. > > thanks > > rahul > > -- > 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] rss feed
hi all, for my project need to generate rss feed and place in folder what to do ? we need to have RSS feed generated and placed inside /feeds folder. Format of these feeds should be valid RSS feed format. These feed should contain whatever information is present in the field or everything in the database table field. Number of entries in the feed should be limited to most recent five articles. Please ensure that generated feed is the valid RSS feed. what thing to use to put rss feed in the folder i know how to generate rss feed generate by but to put in the folder what to do i dont know please help. thanks rahul -- 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 cascading delete
Hi Hilal, You need to use :dependent => :destroy instead of :delete_all because :delete_all doesn't fire any callbacks. That's why it only deletes one level. /Lasse 2010/4/2 Hilal > Hello There: >I am trying to do a deep cascading deletes in rails. > > The schema looks like this: > > Blogs (has many) entries ( has many ) comments > > A blog has n entries, an entry has n comments. > > So, in my Blog model I use > has_many :entries, :dependent => :delete_all > and in my Entry model I use > has_many :comments,:dependent => :delete_all > > The problem I am having is that deleting blogs, will only delete > entries, but will not delete comments. In other words, the cascading > delete isn't deep? > > Am I doing something wrong here? > > Thanks > Hilal > > > -- > 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] Rails cascading delete
On 2 April 2010 08:08, Hilal wrote: > Hello There: > I am trying to do a deep cascading deletes in rails. > > The problem I am having is that deleting blogs, will only delete > entries, but will not delete comments. In other words, the cascading > delete isn't deep? > > Am I doing something wrong here? Try: :dependent => :destroy http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html -- 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 array, javascript and json issue
On Apr 1, 11:29 pm, John Merlino wrote: > Hey all, > > I am unable to get a highcharts plugin to render a chart in a rails > application:http://github.com/loudpixel/highcharts-rails > > I believe it has something to do with the sql queries to the database > placed in a ruby array, which the javascript is unable to intepret. This > is what I have: > > def panels > pass = Student.find_by_sql('SELECT COUNT(*) FROM students WHERE > student_state = 1') > fail = Student.find_by_sql('SELECT COUNT(*) FROM students WHERE > student_state = 2') > Are you expecting pass and fail to be numbers? They're not - Student.find_by_sql always returns an array of student objects. Sounds like you might want count. Fred > student_data = [ > {:name => 'Pass', :y => pass}, > {:name => 'Fail', :y => fail} > ] > pie_label_formatter = ' > function() { > if (this.y > 15) return this.point.name; > }' > > pie_tooltip_formatter = ' > function() { > return "" + this.point.name + ": " + this.y + " %"; > }' > > @pie_chart = > Highchart.pie({ > :chart => { > :renderTo => "pie-chart-container", > :margin => [50, 30, 0, 30] > }, > :plotOptions => { > :pie => { > :dataLabels => { > :formatter => pie_label_formatter, > :style => { > :textShadow => '#00 1px 1px 2px' > } > } > } > }, > :series => [ > { > :type => 'pie', > :data => student_data > } > ], > :subtitle => { > :text => 'April 2010' > }, > :title => { > :text => 'Student Status Chart' > }, > :tooltip => { > :formatter => pie_tooltip_formatter > }, > }) > > Note if I put this: :data => student_data.to_json It actually returns a > json string of my query as text in the browser. Also, if I hard code > values (e.g. :y => 1), it will render the chart properly. However, any > database query will not render the chart properly. So I'm not sure > exactly what the issue is. Any suggestions? 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.
[Rails] Rails 2.3 SafeBuffer leaked evil all over my yaml
I've been googling for a while to find a solution to this, but can't seem to. What's happening is that after upgrading from rails 2.1 to rails 2.3, my YAML started getting, for lack of a better word, 'evil' due to the introduction of the SafeBuffer class. I thought SafeBuffer was related to ERB implementation only but it seems to have affected the output generated by .to_yaml, causing clients that want to parse this yaml to choke (not knowing anything about SafeBuffers). Grepping rails source for SafeBuffer I see nothing that could affect the yaml class...so it seems the safebuffer This is what an evil-ized safebuffered yaml looks like (just a piece of it) BAD/EVIL: somevalue: !str str: "yes" "@_rails_html_safe": false GOOD (before safebuffers) somevalue: yes Any ideas greatly appreciated! Yan -- 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 cascading delete
Hello There: I am trying to do a deep cascading deletes in rails. The schema looks like this: Blogs (has many) entries ( has many ) comments A blog has n entries, an entry has n comments. So, in my Blog model I use has_many :entries, :dependent => :delete_all and in my Entry model I use has_many :comments,:dependent => :delete_all The problem I am having is that deleting blogs, will only delete entries, but will not delete comments. In other words, the cascading delete isn't deep? Am I doing something wrong here? Thanks Hilal -- 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] uninitialized constant MysqlCompat::MysqlRes
Macbook 466 Mac OS X 10.6.3 Rails 2.3.5 Ruby 1.8.7 MySQL mysql-5.1.45-osx10.6-x86 after install mysql gem with "sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config " use "rake db:migrate" but always dispay the error msg: rake aborted! uninitialized constant MysqlCompat::MysqlRes what should I do? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] named_scope when using foreign keys
On 2 April 2010 09:06, jeb wrote: > Hi all, > > I can't get this named scope to work. Each store has a number of > users. Each store can have one manager. I ant to use a nemed scope to > find the manager by name. Have I got this totally backwards? > > Help appreciated > :-) jonas > > > class Store < ActiveRecord::Base > has_many :users, :dependent => :destroy > belongs_to :manager, :class_name => "User", :foreign_key => > "manager_id" > named_scope :manager_name, lambda{|name| {:include > => :manager, :conditions => ['manager.name = ?', name ]}} That looks ok to me, assuming that the stores table has a manager_id column. Remember that the named scope will return an array of stores containing all the stores with a manager of that name. If you have already a store in @store then to get the managers name you just need @store.manager.name of course. If that doesn't help post the error you are getting and the code around the error. 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] named_scope when using foreign keys
On 2 April 2010 09:06, jeb wrote: > class Store < ActiveRecord::Base > has_many :users, :dependent => :destroy > belongs_to :manager, :class_name => "User", :foreign_key => > "manager_id" > named_scope :manager_name, lambda{|name| {:include > => :manager, :conditions => ['manager.name = ?', name ]}} You don't say what errors you're getting, but I'd suggest that if your tables follow the naming conventions, the conditions should be: :conditions => ['managers.name = ?', name ] -- 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: Loading Fixtures Earlier
> Is there any way to have fixtures loaded earlier on in the testing > process, or is there some proper Rails-provided way to seed the test > database? Yes. From 2.3.4 onwards there is db/seeds.rb file .You can write put data there. For more information please watch this Railscast http://railscasts.com/episodes/179-seed-data Sijo -- 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: providing feedback to users
It can by manage if you you using AJAX, and it's many ways to do it, there one: just show some pleas wait on 'ajax start' event and hide this one on 'ajax end' event. If you choose jqure (jquery.com) it would look like: $("#loading").ajaxStart(function(){ $(this).show(); }); ("#loading").ajaxStop(function(){ $(this).hide(); }); http://api.jquery.com/ajaxStart/ http://api.jquery.com/ajaxStop/ On Apr 2, 1:25 am, mstoth wrote: > I have an application which does some time-consuming work after a form > is submitted. > I'd like to have a little message saying "please wait" but I'm not > sure how to implement that. > > I'm thinking somehow you have to send a page to the browser from the > method that is being called by the form. > Sounds like a basic thing but I'm kind of new to RoR. > > Any ideas? > > -Michael -- 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] named_scope when using foreign keys
Hi all, I can't get this named scope to work. Each store has a number of users. Each store can have one manager. I ant to use a nemed scope to find the manager by name. Have I got this totally backwards? Help appreciated :-) jonas class Store < ActiveRecord::Base has_many :users, :dependent => :destroy belongs_to :manager, :class_name => "User", :foreign_key => "manager_id" named_scope :manager_name, lambda{|name| {:include => :manager, :conditions => ['manager.name = ?', name ]}} -- 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] Weird date/time incompatibility
On 2 April 2010 05:38, Dudebot wrote: > I've uploaded my development project to my production server, and am > experiencing an odd effect. > > All database find methods in which the date is passed as a param are > coming up nil -- it seems that there's an incompatibility in the date/ > time format in there somewhere. > > E.g. in the view, obtaining @date from the controller to the index > > labs = Lab.all( :conditions => [ "patient_id = ?", id ], :order => > "drawn DESC" ) > @dates = [] > labs.each { |lab| @dates << lab.drawn } > > Then in the index view, > <% for date in @dates %>... > <%= link_to ... :date => date... %> Have you checked the html of the page in the browser to check that the links are correct? Compare the html with that seen in the development environment. > > Then back in the show method in the controller: > @date = params[ :date ] Have you checked the log to see whether the params are the same in the development and production environment. You may have to change the logging setup in config/environments/production.rb to see this. > then > LabData.first ... :conditions => ... 'labs.drawn' => date Again check the log to see what sql is being used. Have you checked in the db that the records are there? Hopefully one of the above will give you some clue. Colin > isn't finding it on the production server, but it was on the > development machine. > > I've tried fiddling with the time zone settings on the production > server, no luck. > > Has anyone encountered such a problem? Any ideas how to fix it? > > Many 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. > > -- 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.