Re: [Rails] Re: Complex abilities and scoping of records
On Fri, Feb 22, 2013 at 3:51 AM, javinto wrote: > Have you been looking at CanCan? > > I've implemented a similar situation with CanCan. It will not cover your > needs for 100% but it will do a lot. > Yes I have been looking at cancan. I have also been looking at Consul. Of the two Consul seems to have a little more power and is scope based so it's probably worth giving a shot but it looks like cancan has won the popularity war anyway. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Complex abilities and scoping of records
I have the following scenario. Users have various levels of ability. They can only view and edit their own records (their profile). Their managers can only view and edit their employees records. The regional managers can view and edit only the people in their regions and the corporate headquarters can view and edit all records. There are multiple regions so somebody can be the manager of the north region and somebody is the manager of the south region. They both have the role of "regional manager". Of course this also applies to any of the child relations as well (addresses, phone numbers etc). I am struggling with a clean way to write a controller which would only show the records they have the right to on the index method. I want to avoid silly and complex case statements and I also want avoid roles like "regional manager north". I figure somebody here has run into this problem. What is the most elegant way to solve this problem. Cheers. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Postgres COPY from STDIN
> conn = ActiveRecord::Base.connection_pool.checkout > raw = conn.raw_connection > raw.exec("COPY tablename (col1, col2, col3) FROM STDIN") > # open up your CSV file looping through line by line and getting the line > into a format suitable for pg's COPY... > rc.put_copy_data line > # once all done... > rc.put_copy_end > while res = rc.get_result do; end # very important to do this after a copy > ActiveRecord::Base.connection_pool.checkin(conn) > I did try that and it doesn't work. Not only doesn't it work but it fails silently. I wrote a more elaborate routine which I can get to run without errors but it still doesn't add the records in the table. conn.transaction do rc = conn.raw_connection rc.exec "TRUNCATE TABLE #{table_name};" if options[:truncate] sql = "COPY #{table_name} (#{field_list.join(',')}) FROM STDIN #{sql_parameters} " p sql rc.exec(sql) begin if method == 1 rc.put_copy_data text + "\\.\n" else text.each_line { |line| rc.put_copy_data(line) } end rescue Errno => err errmsg = "%s while reading copy data: %s" % [err.class.name, err.message] puts "an error occured" end if errmsg rc.put_copy_end(errmsg) puts "ERROR #{errmsg}" else rc.put_copy_end end while res = rc.get_result puts "Result of COPY is: %s" % [res.res_status(res.result_status)] end puts "end" end #transaction Maybe it's a bug in the PG gem? -- You received 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.
[Rails] Postgres COPY from STDIN
I have done some googling to try and figure out how I can use COPY FROM STDIN with rails and have ran into some posts on stackoverflow or the mailing list but none of them seem to be working with rails 3.2 Does anybody have a working example of using COPY FROM STDIN? Some things I have tried https://bitbucket.org/ged/ruby-pg/src/tip/sample/copyfrom.rb http://blog.edseek.com/archives/2009/04/26/putline-undefined-for-pgconn/ and similar variations. Nothing seems to be working though. 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-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.
Re: [Rails] Rails 3.1 and minitest
I'll bump this. I too am interested in getting minitest working especially with autotest. I kind of got something going but it's ugly and doesn't work with autotest. On Thu, Oct 20, 2011 at 12:37 PM, djangst wrote: > I'm looking for a simple way to integrate minitest/spec with Rails > 3.1. Anybody have it working? > > There's an older article on MetaSkills about this but it adds stuff I > don't want. > > -- > You received 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.
Re: [Rails] Ubuntu: Best IDE
Rubymine. Has full support for git (and everything else you can think of) On Fri, Nov 18, 2011 at 3:17 PM, Mathew S. wrote: > Anything but Aptana Studio > > > > > I have not had good luck with Aptana... So Please give me a list of your > favs. > > > And how you would open up the files with git onto the program :) <3 > > -- > 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-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.
[Rails] matching each subdomain to a different controller.
I want to create routes that map a subdomain to a controller. Each controller will have the same actions but they will have different views and will do different things. So basically I want something like this imaginary route constraints(app = App.new) do controller app.controller do root :to => "index" get => "sign_up" 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-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.
[Rails] using bundler while developing a gem.
I want to be able to specify something like this. group :development do gem 'mygem', :path => File.expand_path(File.dirname(__FILE__) + '/../mygem') end group :production do gem 'bingatron-core', :git => "g...@github.com:myaccount/mygem.git" end Bundler doesn't like this at all and complains I am specifying the same gemname twice I tried doing something like if ::Socket.gethostname == 'myhost' gem ... but that doesn't work either because the Gemfile.lock ends up with the wrong gem when capistrano deploys. What is a good strategy for dealing with 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-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.
Re: [Rails] Re: postgres default values don't work with active record
> > I don't think so - I think activerecord is expecting to be able to > read the default values out of the database schema, although that > assumes that the default is some fixed value. > It should be possible to do something like this though, since updates > only write unchanged columns. > In postgres sometimes the default values are functions like for example UUID fields. It would work fine if it sent DEFAULT instead of NULL for the missing fields and of course it could just not mention them either. I was wondering if there is a flag somewhere in AR that says "Don't send NULLs for missing attributes" or something. -- You received 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.
[Rails] postgres default values don't work with active record
Activerecord sets the columns that are not specified to NULL. Postgres presumes that since your insert statement said to set the column to null you meant to set it null and ignores the default. Is there a way to tell activerecord not set missing attributes to null? 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-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.
Re: [Rails] Re: TypeError: can't convert nil into Integer
> Having a column called hash is weird - Object has a method called > hash, which your attribute will shadow, which could mess up trying to > call uniq on an array containing objects of your class > > Fred That was the case. Can't have a column called hash in your models. You trip on the magic. -- You received 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.
[Rails] TypeError: can't convert nil into Integer
I am getting this error with a very simple model and schema. The record saves even though an error has been generated. I have tried this with both postgres and mysql. Here is the model. class Person < ActiveRecord::Base end Here is a transcript.. p = Person.new => # ree-1.8.7-2011.03 :002 > p.first_name = 'tim' => "tim" ree-1.8.7-2011.03 :003 > p.save TypeError: can't convert nil into Integer from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:322:in `uniq' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:322:in `commit_transaction_records' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:165:in `transaction' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:207:in `transaction' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:290:in `with_transaction_returning_status' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:240:in `save' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:251:in `rollback_active_record_state!' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:239:in `save' from (irb):3 ree-1.8.7-2011.03 :004 > Person.all => [#] ree-1.8.7-2011.03 :005 > Here is the SQL statement generated INSERT INTO `people` (`date_of_birth`, `updated_at`, `gender`, `date_of_death`, `created_at`, `hash`, `first_name`, `middle_name`, `age`, `status`, `last_name`, `email`, `state`) VALUES (NULL, '2011-05-12 03:39:33', NULL, NULL, '2011-05-12 03:39:33', NULL, 'tim', NULL, NULL, 0, NULL, NULL, 0) Here is the migration create_table :people do |t| t.string :hash t.string :first_name t.string :last_name t.string :middle_name t.date :date_of_birth t.date :date_of_death t.integer :age t.string :gender t.string :email t.integer :state , :default => 0 t.integer :status , :default => 0 t.timestamps end add_index :people, :email add_index :people, :hash add_index :people, :state add_index :people, :status So there is nothing weird at all. Very strange -- You received 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.
[Rails] Incomplete multibyte character when using postgres
Has anybody ran into this error with rails and postgres? I get this quite a bit and I have no idea why. -- You received 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.
[Rails] Forking to save memory when using REE.
I have a few dozen daemons and all of them load the rails environment. Each one uses the DaemonSpawn gem to daemonize itself. I was thinking that I could save a lot of memory if I could somehow share the rails environment between all of these daemons. It seems to me the simplest thing to do would be to use the daemonize gem and do a Daemons.run('myserver.rb') for each of the daemons but I am not sure that this would actually solve my problem or not. I am wondering if anybody else has had this issue and what they did to solve it. 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-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.
[Rails] Pentaho
I did a quick search for pentaho on the mailing list and a post came up from 2008. Has anybody integrated pentaho with rails yet? -- You received 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.
Re: [Rails] Weird form behavior
On Fri, Feb 11, 2011 at 4:40 PM, Tim Uckun wrote: > On Fri, Feb 11, 2011 at 4:38 PM, Jim Ruther Nill wrote: >> I'm not sure but if you look at >> http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html >> your params does not have the same format as the one stated in the link. It >> should be >> "contact_methods_attributes"=>[{"details"=>"test", "id"=>"1", >> "_destroy"=>"false"}] > The problem turned out to be attr_accessible You have to put contact_methods_attributes in there and not contact_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-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.
Re: [Rails] Weird form behavior
On Fri, Feb 11, 2011 at 4:38 PM, Jim Ruther Nill wrote: > I'm not sure but if you look at > http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html > your params does not have the same format as the one stated in the link. It > should be > "contact_methods_attributes"=>[{"details"=>"test", "id"=>"1", > "_destroy"=>"false"}] That's interesting. I thought fields_for would have taken care of that automatically. I'll try manually building the fields and see what happens. -- You received 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.
Re: [Rails] Weird form behavior
On Fri, Feb 11, 2011 at 4:07 PM, Jim Ruther Nill wrote: > i don't know if location is a special term or not. But I have a question, do > have an attr_accessible line in your user model? > If you do, check that you have the location attribute listed there. DOH!. Yes that was the problem... Now for the second part class User has_many :contact_methods accepts_nested_attributes_for :contact_methods, :allow_destroy => true end The form has this (from above) = render 'contact_methods' , {:f => f} the partial looks like this. = f.fields_for :contact_methods do |c| %tr %td = c.object.icon.nil? ? nil : image_tag(c.icon) # %td = c.text_field :details ,:class => "text-input" %td - unless c.object.new_record? = c.hidden_field :_destroy = link_to 'Delete', '#', :class => 'delete_contact_method' This displays the records fine, submits them as "contact_methods_attributes"=>{"0"=>{"details"=>"test", "id"=>"1", "_destroy"=>"false"}} but it won't update them. There is no error message and @user.save! does not throw an exception. I created the contact method by hand but it won't delete it or update it. The ContactMethod has no attr_accessable and I added :contact_methods to the user attr list So why doesn't the nested_atrributes work? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-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.
[Rails] Weird form behavior
I am having a confounding issue and I hoping somebody can give me a clue as to what is happening. I have one field in my table which is not updating via the form. It updates fine if I extract the information from the params and do it manually in the controller. On this form the ebmedded form is also not updating any of the child records but first I'd like to figure out what is going on here. Basically you have this User has_many :contact_methods. The form looks like this. - form_for (@user, :url => edit_profile_url) do |f| = f.label :email %br/ = f.text_field :email, :class => "text-input" %br/ = f.label :name %br/ = f.text_field :name, :class => "text-input" %br/ = f.label :location %br/ = f.text_field :location, :class => "text-input" %br/ = f.label :skills_list , 'My skills are (comma separated list)' %br/ = f.text_field :skill_list, :label => 'My skills are (comma separated list)' , :class => "text-input" %br/ = f.label :bio %br/ = f.text_field :bio, :label => ' Brief personal summary' , :class => "text-input" %br/ = render 'contact_methods' , {:f => f} =f.submit Every field in here is updatable except the location field. For some odd reason it won't update the location field when you submit the form. If I do this in the controller it works fine. @user.update_attributes(params[:user]) location = params[:user][:location] @user.location = location if location so why is only this one field not updating while everything else is? Is "location" a special term? -- You received 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.
Re: [Rails] Making destroy_all work faster.
> > No. Destroy has to instantiate each object prior to actually removing it > from the database in order to run any before/after destroy call backs. > > You can speed things up if you don't need this by tweaking the :dependent > option to has_many so that it will simply use SQL's DELETE on the child > objects... but that of course won't run any callbacks (your own, or Rail's > counter cache, etc.) Actually it doesn't HAVE to instantiate them if it can query the relationships in a meaningful matter. Of course we know that it CAN query those relationships and calculate what has to be deleted. I did this id_list = Model.select(:id).where(whereclause)..map { |r| r.id }.join(',') This gives you a list of comma delimited ids ActiveRecord::Base.transaction do Children.delete_all('parent_id in (#{id_list})") Children2.delete_all('parent_id in (#{id_list})") Children3.delete_all('parent_id in (#{id_list})") end In my case I had about a half a dozen children. The delete time for my records went from four minutes to under 30 seconds. That's a pretty big gain. Of course I had to hand code my relationships and if I add something new I will have to modify my method. It would be really nice if somebody way smarter than me implemented this into AR. -- You received 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.
[Rails] Making destroy_all work faster.
When I call destoy_all on a model with a where clause AR iterates though each record in the recordset and calls destroy on each item. This seems highly inefficient to me. Wouldn't it be better to call delete from child records where foreign_id in (parent ids)? In other words shouldn't destroy all destroy all the children for all the items in one shot? I am having to manually do destroy all on my children when I have large number of records to delete so I am wondering if there is a more elegant way of handling this. 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-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.
Re: [Rails] Re: Having problems with rails connectivity to postgres (libpq?)
> I suspect what is happening in my case, (and maybe yours), is the SSL > connection is "renegotiating" and failing, which is documented > elsewhere (google postgresql ssl renogotiation) > > So far I have not seen this issue since I switched to a local > connection. Although I have two other older rails apps running > presumably with SSL and they have not exhibited this error. I have turned it off. Let's see if the problem occurs again. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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: Having problems with rails connectivity to postgres (libpq?)
On Sun, Dec 19, 2010 at 7:26 PM, Jim Morris wrote: > I've spent the day trying to track this down. I am not seeing it with > my older rails/activerecord app, only with the newer rails 3.0.3/ > sequel app. I am seeing it using activerecord on rails 3.0.3 The problem just occured and although the client is constantly putting out errors like this PGError: lost synchronization with server: got message type "o", length 544501536 PGError: lost synchronization with server: got message type "�", length -65536 PGError: lost synchronization with server: got message type "�", length -65536 PGError: lost synchronization with server: got message type "�", length -65536 PGError: lost synchronization with server: got message type "o", length 544501536 PGError: lost synchronization with server: got message type "o", length 544501536 PGError: lost synchronization with server: got message type "o", length 544501536 there is nothing in the postgres log. > > I "think" it may be the ssl connection to postgresql. On newer Ubuntu > systems a local tcp connection uses ssl by default (kind of odd but > still). > > What I did was to remove the host,username,password settings from > database.yml which forced it to use a local unix pipe to connect, so > far I have not seen this error, but it is pretty infrequent. > I can't do this because my database is on another server. > You can also switch off SSL in the posgresql,conf file., check to see > if ssl is set to true in that file, or when yo connect at the command > line with > >> psql -h localhost yourdbname > > if it prints out SSL connection (cipher: DHE-RSA-AES256-SHA, bits: > 256) then it is using SSL. It's definitely using SSL. I might try turning off the SSL and see if that does any good. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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: Having problems with rails connectivity to postgres (libpq?)
On Sat, Dec 18, 2010 at 11:05 AM, Jim Morris wrote: > I have recently deployed a similar setup, Ubuntu 10.04, pgsql 8.4, > rails 3.0.3, pg gem etc. > > I have started to see this error occasionally, that request fails then > subsequent requests are OK, the pgsql log says the client > disconnected! > In my case the application is unable to connect back to the database. > Sequel::DatabaseDisconnectError (PGError: server closed the connection > unexpectedly > I was thinking it might be an activerecord problem but if you are having the same issue with sequel maybe it's at a lower level than that. Somebody suggested it might be a connection pool or a thread pool issue but I have no way of testing that. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Having problems with rails connectivity to postgres (libpq?)
I have some daemons that connect to a PG database and are pretty busy. Every few days at least one of them starts failing with this error. PGError: lost synchronization with server: got message type "something" Sometimes the message type is an empty string. Other times it's a letter like "E" or something. It seems to vary from incident to incident. This is highly annoying because at this point the daemon becomes useless. If I stop the daemon and start it again everything works fine. A few days later some other daemon or maybe the same one will fail with a similar message. I am running the latest version of rails 3.0.3 on an up to date ubuntu connected to postgres 8.4. Any idea of what is going on? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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: Getting postgres connection errors
This problem started with the recent update to rails. I also think it may have to do with this statement ActiveRecord::Base.connection_pool.clear_stale_cached_connections! The postgres mailing list tells me these errors have to do with threading in libpq. On Wed, Nov 3, 2010 at 11:41 AM, Tim Uckun wrote: > I am getting these types of errors quite frequently and am wondering > what may be causing them or how to fix them. > > PGError: lost synchronization with server: got message type "T", > length 1409286191 > PGError: lost synchronization with server: got message type "T", > length 1409286191 > PGError: lost synchronization with server: got message type "T", > length 1409286191 > PGError: lost synchronization with server: got message type "T", > length 1409286191 > PGError: lost synchronization with server: got message type "T", > length 1409286191 > PGError: lost synchronization with server: got message type "T", > length 1409286191 > PGError: lost synchronization with server: got message type "e", > length 980640103 > PGError: lost synchronization with server: got message type "e", > length 980640103 > PGError: lost synchronization with server: got message type "e", > length 980640103 > > > They tend to happen after the daemon is running for a while (a day or > two). Needless to say once this happens the daemon is not working > anymore. > > Any help in diagnosing and solving this problem would be much appreciated. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Getting postgres connection errors
I am getting these types of errors quite frequently and am wondering what may be causing them or how to fix them. PGError: lost synchronization with server: got message type "T", length 1409286191 PGError: lost synchronization with server: got message type "T", length 1409286191 PGError: lost synchronization with server: got message type "T", length 1409286191 PGError: lost synchronization with server: got message type "T", length 1409286191 PGError: lost synchronization with server: got message type "T", length 1409286191 PGError: lost synchronization with server: got message type "T", length 1409286191 PGError: lost synchronization with server: got message type "e", length 980640103 PGError: lost synchronization with server: got message type "e", length 980640103 PGError: lost synchronization with server: got message type "e", length 980640103 They tend to happen after the daemon is running for a while (a day or two). Needless to say once this happens the daemon is not working anymore. Any help in diagnosing and solving this problem would be much appreciated. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Sharing sessions between a rails3 app and a rails2 app. Rails 2 app crashes.
> > I'll give that a try and see if it works. > > Another thing I noticed was that rails3 sets a 'session_id' and rails2 > sets a :session_id > Just to follow up on this... Your workaround worked but it only went so far. Now I am getting this error. Session contains objects whose class definition isn\'t available. Remember to require the classes for all objects kept in the session. (Original exception: #{const_error.message} [#{const_error.class}]) I am not going to chase this down. Who knows what object it's complaining about. I think I am just going to set a cookie and track it on the other app. That part seems to be working OK. I hope this saves somebody lots of work. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Sharing sessions between a rails3 app and a rails2 app. Rails 2 app crashes.
> Well it looks like the core issue is that HashWithIndifferentAccess > became ActiveSupport::HashWithIndifferentAccess in rails 3. The > session is a serialized ruby object which somewhere is saying that it > contains an instance of class ActiveSupport::HashWithIndifferentAccess > and rails 2 is complaining that it doesn't know what that is. > From what you've said I'm not sure why it works the first time. It > could be that something on the second request is storing such a hash > or that a development mode class loading oddity means that initially > ActiveSupport::HashWithIndifferentAccess is able to find the top level > class. You may be able to solve this by defining > ActiveSupport::HashWithIndifferentAccess in your rails 2 app > I'll give that a try and see if it works. Another thing I noticed was that rails3 sets a 'session_id' and rails2 sets a :session_id I don't know why they changed that. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Sharing sessions between a rails3 app and a rails2 app. Rails 2 app crashes.
On Tue, Aug 24, 2010 at 7:04 AM, gkaykck wrote: > you should share some code here, there could be many reasons for that > Ok it's pretty simple. In rails 2 app I have something like this. Initializers session_store.rb ActionController::Base.session_store = :cookie_store ActionController::Base.session = { :key => '_session_identifier', :secret => secret } enviroment.rb config.action_controller.session = { :domain => '.domain.name' } In the rails 3 application I have this. Rails.application.config.session_store :cookie_store, :key => '_session_identifier', :domain => ".domain.name" Rails.application.config.secret_token = secret Rails.application.config.cookie_secret = secret in the rails3 app I set the variables like this session['tim'] = 'This is a session variable' cookies['tim'] = 'This is a cookie variable' in the rails2 app @tim = session['tim'] @cookie = cookies['tim'] The steps needed to crash the rails 2 app. go to domain.name cookies and session variables are set go to subdomain name cookie and session variable is read properly go back to domain name, reload go back to subdomain, reload the applicaiton crashes -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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] Sharing sessions between a rails3 app and a rails2 app. Rails 2 app crashes.
Hey all. I have two apps. One is a rails3 app and the other is a rails 2 app. Using proxying I am routing actions in the myapp.com/foo to the rails2 app. It almost works! I can set a session variable and a cookie variable on the first app (myapp.com) and then read them on the second app (myapp.com/foo). It only works the first time though. If I go back to myapp.com and then revisit myapp.com/foo the rails2 application crashes with the error NameError (uninitialized constant ActiveSupport::HashWithIndifferentAccess): This error is raised when any attempt to access the session variable is made. I first thought it was because rails3 set a session['session_id'] and rails2 set a session[:session_id] so wrote some code to delete session['session_id'] but that didn't solve the problem. The setup is pretty straightforward. They both use cookie sessions (for now). They both have the same key, secret and domain. nginex does the proxying. So what is going on here? Any clues? Why does it work the first time but crash if you hit the back button and the forward button? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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] Hash.from_xml does not handle attributes as of rails3 beta4
Can anybody confirm whether or not this has been fixed in the rc releases? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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] curl works when testing JSON response but the functional and integration tests do not work.
I am trying to test an action which is supposed to give a json response The url goes something line /blah/model.json When I POST to that URL using curl like this curl -H "Content-Type:application/json" -H "Accept:appn/json"-d "data" http://localhost:3000/blah/model.json it works just fine. In my test functional test I have this method def post_json (data) post "/blah/model.json", {:data => data.to_json}, {'Content-Type' => 'application/json', 'Accept' => 'application/json'} end When I run this test I get the error ActionController::UnknownAction: No action responded to /blah/model.json. Actions: index The route is defined like this. map.connect '/blah/:model.:format', :controller => 'xfer', :action => 'index' , :conditions => { :method => :post } -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] How to determine the running controller in rails3
The @controller and @template are returning nil in rails3. What is the proper way to refer to the current controller in rails3? Cheers. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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] hi - a favour required immediately
On Sat, Apr 10, 2010 at 4:48 AM, Julian Leviston wrote: > http://code.google.com/webtoolkit/ > It would be kind of cool if there was a version of this for ruby or jruby. Just as an alternative to rails. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, 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: Testing and SQL views.
> > > The only code I can see that affects triggers is in the original > PostgreSQLAdapter#disable_referential_integrity method. It disables > triggers during a block and re-enables them afterwards. As far as I > remember, this is used to load fixtures while temporarily suspending the > triggers. As fixture files are loaded one by one without regard for > foreign keys, the temporarily violated constraints would cause an > exception. I don't think the behavior you're seeing is related to views > Yes that's where the problem occurs. That code iterates over the tables collection. The problem is that you have alias_method_chain on tables which returns the views as well as the tables and of course the code fails when it hits a view. I commented out the alias method chain line and it works. I hope I didn't break something else. > > > Do I have to make my models which derive from view inherit from > > AR:View? is > > No, that's just for convenience if you like to re-use associations from > other models. > > Ah. Ok 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-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 -~--~~~~--~~--~--~---
[Rails] Re: Testing and SQL views.
> > > http://github.com/aeden/rails_sql_views/tree/master > > and my heavily hacked version > > http://github.com/mschuerig/rails_sql_views/tree/master > > My version works with Rails 2.3.2, loads only the adapters that are > really needed, and adds ActiveRecord::View as an abstract superclass for > views that are mostly based on another model. AR::View can clone > association definitions from the model to the view, although I haven't > implemented all kinds yet. The existing functionality works on > PostgreSQL, regarding the others, I'm not sure right now. > > Michael I have downloaded your code and it does work a lot better. Although it fixed the original problem now it presents another problem Either the rails framework or the postgres adapter attempts to change the triggers in the "table" using ALTER TABLE which causes an error. Do I have to make my models which derive from view inherit from AR:View? --~--~-~--~~~---~--~~ You received 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 -~--~~~~--~~--~--~---
[Rails] A bug in sweeper.rb? [was: A frustrating and strange error when config.action_controller.perform_caching = true]
I fired up the debugger and watched the code happen tonight. The problem occurs if the config.action_controller.perform_caching = true in your environment. It's not set to true in development but it is set to true in production and staging. The problem occurs not in my controllers but in sweeping.rb (part of rails). Rails calls this code for every controller which was instantiated in the same request ( I think). Running the page it "sweeps" the following controllers in this order. # # The problem is that on the second call to clean up MatchController it pukes. The code snippets in sweeping.rb are.. The cleanup is in the following method of sweep.rb def after(controller) callback(:after) if controller.perform_caching # Clean up, so that the controller can be collected after this request self.controller = nil end A little later.. def callback(timing) controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}" action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}" __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true) __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true) end The problem is that after the first controller has been cleared controller is nil when it gets to the callback (even if it's not nil when it hits the after method) I am not quite sure what is the problem but could this be a bug in sweeper.rb? --~--~-~--~~~---~--~~ You received 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 -~--~~~~--~~--~--~---
[Rails] Re: Testing and SQL views.
> > Have a look at > > http://github.com/aeden/rails_sql_views/tree/master > > and my heavily hacked version I looked at this. It didn't work in my setup. > > > http://github.com/mschuerig/rails_sql_views/tree/master > > My version works with Rails 2.3.2, loads only the adapters that are > really needed, and adds ActiveRecord::View as an abstract superclass for > views that are mostly based on another model. AR::View can clone > association definitions from the model to the view, although I haven't > implemented all kinds yet. The existing functionality works on > PostgreSQL, regarding the others, I'm not sure right now. > I'll take a look at this next. --~--~-~--~~~---~--~~ You received 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 -~--~~~~--~~--~--~---
[Rails] Re: Testing and SQL views.
On Sat, Apr 18, 2009 at 12:43 AM, Harold A. Giménez Ch. < harold.gime...@gmail.com> wrote: > What DBMS are you using? The alternative is a "materialized view". > postgres. > >>> >>> Name the fixtures.yml file after the actual target table, not the view. >>> >>> >> I'll give that a shot. Thanks... >> >> This didn't work. There are no fixtures with the names of the views and the test suite still tries to run a delete from the views. I can't believe rails has no conception of views. Must be the mysql heritage (I know mysql has views now). --~--~-~--~~~---~--~~ You received 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 -~--~~~~--~~--~--~---
[Rails] A frustrating and strange error when config.action_controller.perform_caching = true
Hello all. I am having a hell of a problem and it's driving me nuts. I get the following error (undefined method `controller_name' for nil:NilClass): but only when config.action_controller.perform_caching = true I googled around some and found this thread http://groups.google.com/group/communityengine/browse_thread/thread/b84154e5228bf9f3which suggests it may be a conflict with a pllug in controller but I don't see any two controllers with the same name. This particular controller is using activescaffold and I think that might be a part of the problem though I can't be sure. As you can see from the stacktrace rails has finished rendering the page and seems to throw a fit during sweeping.rb. Also none of my controllers are mentioned in the stacktrace. What can I do to figure out why this is failing? This is driving me nuts. End of component rendering 2009-04-17T13:22:22+01:00 : DEBUG : Rendered match/_provider_summary (37.0ms) 2009-04-17T13:22:22+01:00 : FATAL : NoMethodError (undefined method `controller_name' for nil:NilClass): /vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb:83:in `callback' /vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb:65:in `after' /vendor/rails/actionpack/lib/action_controller/filters.rb:208:in `around_proc' /vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `call' /vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `evaluate_method' /vendor/rails/actionpack/lib/action_controller/filters.rb:184:in `call' /vendor/rails/actionpack/lib/action_controller/filters.rb:635:in `run_before_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:615:in `call_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in `perform_action_without_caching' /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `passenger_orig_perform_action' /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache' /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `passenger_orig_perform_action' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/railz/request_handler.rb:53:in `perform_action' /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send' /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support' /vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process' /vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:183:in `handle_request' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:123:in `dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in `synchronize' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in `dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:39:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/railz/request_handler.rb:38:in `process_request' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/abstract_request_handler.rb:197:in `main_loop' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/railz/application_spawner.rb:340:in `start_request_handler' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/railz/application_spawner.rb:298:in `handle_spawn_application' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/utils.rb:176:in `safe_fork' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/railz/application_spawner.rb:296:in `handle_spawn_application' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/abstract_server.rb:332:in `__send__' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/abstract_server.rb:332:in `main_loop' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/abstract_server.rb:182:in `start_synchronously' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/lib/phusion_passenger/abstract_server.rb:149:in `start' /usr/local/lib/ruby/gems/1.8/gems/passe
[Rails] Re: Testing and SQL views.
> > > Name the fixtures.yml file after the actual target table, not the view. > > I'll give that a shot. 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-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 -~--~~~~--~~--~--~---
[Rails] Testing and SQL views.
The tests want to execute "delete * from TABLENAME" and this causes problems when the table is actually a view. Is there an easy way to deal with this issue? --~--~-~--~~~---~--~~ You received 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 -~--~~~~--~~--~--~---
[Rails] Re: Neither from_xml nor from_Json work in rails 2.1
> > Is timezone a protected attribute (as in attr_protected or not on the > list given to attr_accessible) ? No. It's changeable by the web GUI too. Also if that was the case you'd expect the validation to throw up an error right? > Is the accessor function timezone= overwridden ? Does it work if you > change other attributes? No. It also doesn't work if you attempt to change other attributies. Change the login field to "tm_user"changed" >> j = "{\"user\": {\"salt\": \"1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\", >> \"activated_at\": \"2008-11-19T22:12:07Z\", \"remember_token_expires_at\": >> null, \"crypted_password\": \"b695db100847aa269fb477443a289d875cf2e001\", >> \"password_reset_code\": null, \"lock_version\": 5, \"activation_code\": >> \"bab0c2bc67d43b6871005559b114b9b62b7b70bb\", \"timezone\": \"ABC\", \"id\": >> 3, \"enabled\": true, \"address_id\": null, \"remember_token\": null, >> \"company_id\": 3, \"login\": \"tm_user_changed\", \"email\": \"[EMAIL >> PROTECTED]"}}" >> u.from_json(j) => # >> Nope no change. Let's save it. >> u.save => true >> u.login => "tm_user" >> Didn't change. --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Neither from_xml nor from_Json work in rails 2.1
> Minus your mysterious 'change the xml' that worked for me.If you could > produce a more precise example (or at least elaborate on "Doesn't > work" (raises an exception, does nothing, has the wrong attributes, > something else...) > you might get a more helpful response. Let's see. u = User.find(3) => # >> u.to_xml => "\n\n 2008-11-19T22:12:07Z\n bab0c2bc67d43b6871005559b114b9b62b7b70bb\n \n 3\n b695db100847aa269fb477443a289d875cf2e001\n [EMAIL PROTECTED]\n true\n 3\n 4\n tm_user\n \n \n \n 1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\n UTC\n\n" Change the XML. Change the timezone from UTC to ABC a = "\n\n 2008-11-19T22:12:07Z\n bab0c2bc67d43b6871005559b114b9b62b7b70bb\n \n 3\n b695db100847aa269fb477443a289d875cf2e001\n [EMAIL PROTECTED]\n true\n 3\n 4\n tm_user\n \n \n \n 1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\n ABC\n\n" Apply it back to the record. >> u.from_xml(a) > u.from_xml(a) => # M. timezone is still UTC. Let's save it. >> u.save => true >> u => # Looks like the time zone never got changed. Let's try with json >> u.to_json => "{\"user\": {\"salt\": \"1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\", \"activated_at\": \"2008-11-19T22:12:07Z\", \"remember_token_expires_at\": null, \"crypted_password\": \"b695db100847aa269fb477443a289d875cf2e001\", \"password_reset_code\": null, \"lock_version\": 5, \"activation_code\": \"bab0c2bc67d43b6871005559b114b9b62b7b70bb\", \"timezone\": \"UTC\", \"id\": 3, \"enabled\": true, \"address_id\": null, \"remember_token\": null, \"company_id\": 3, \"login\": \"tm_user\", \"email\": \"[EMAIL PROTECTED]"}}" >> j = "{\"user\": {\"salt\": \"1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\", >> \"activated_at\": \"2008-11-19T22:12:07Z\", \"remember_token_expires_at\": >> null, \"crypted_password\": \"b695db100847aa269fb477443a289d875cf2e001\", >> \"password_reset_code\": null, \"lock_version\": 5, \"activation_code\": >> \"bab0c2bc67d43b6871005559b114b9b62b7b70bb\", \"timezone\": \"ABC\", \"id\": >> 3, \"enabled\": true, \"address_id\": null, \"remember_token\": null, >> \"company_id\": 3, \"login\": \"tm_user\", \"email\": \"[EMAIL PROTECTED]"}}" => "{\"user\": {\"salt\": \"1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\", \"activated_at\": \"2008-11-19T22:12:07Z\", \"remember_token_expires_at\": null, \"crypted_password\": \"b695db100847aa269fb477443a289d875cf2e001\", \"password_reset_code\": null, \"lock_version\": 5, \"activation_code\": \"bab0c2bc67d43b6871005559b114b9b62b7b70bb\", \"timezone\": \"ABC\", \"id\": 3, \"enabled\": true, \"address_id\": null, \"remember_token\": null, \"company_id\": 3, \"login\": \"tm_user\", \"email\": \"[EMAIL PROTECTED]"}}" >> j => "{\"user\": {\"salt\": \"1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\", \"activated_at\": \"2008-11-19T22:12:07Z\", \"remember_token_expires_at\": null, \"crypted_password\": \"b695db100847aa269fb477443a289d875cf2e001\", \"password_reset_code\": null, \"lock_version\": 5, \"activation_code\": \"bab0c2bc67d43b6871005559b114b9b62b7b70bb\", \"timezone\": \"ABC\", \"id\": 3, \"enabled\": true, \"address_id\": null, \"remember_token\": null, \"company_id\": 3, \"login\": \"tm_user\", \"email\": \"[EMAIL PROTECTED]"}}" >> u.from_json(j) => # >> u.save => true >> u => # >> Exact same story. --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Neither from_xml nor from_Json work in rails 2.1
If you have the need to do a lot of XML processing you are better off staying away from rails completely. The State of SOAP on rails is a mess to the point of being practically unusable. The XML and json deserialization is like playing russian roulette with five bullets in the chamber. Try it yourself. u = User.find(1). xml = u.to_xml ... Change the xml. u.from_xml(xml) Doesn't work. Same with json. Doesn't work. Half the time from_xml can't parse the xml to_xml put out. --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] SOAP4R seems to conflict with actionwebservice.
I am getting the following error when any test fails "uninitialized constant SOAP::SOAPNamespaceTag" If any exception is raised it raised this exception instead. Very strange. I have googled around a bit and some people have suggested some workarounds for the older versions of SOAP4R or rails but none of them work with the 1.5 version of SOAP4R and 2.1 version of rails. Does anybody have a solution to this problem? --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Actionwebservice as a SOAP client to .NET services.
> You probably want SOAP4R. See http://rubyforge.org/projects/soap4r/ > and also my tutorial at > http://markthomas.org/2007/09/12/getting-started-with-soap4r Thanks. I have written a stand alone ruby script that fetches the data I want. The next step is to see if I can make it work in rails. --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Actionwebservice as a SOAP client to .NET services.
I have read the (scant) documentation on the datanoise actionwebservice gems and can't figure out how you are supposed to structure the SOAP client. Has anybody ever used actionwebservice as a client? If so could somebody please put a sample someplace? 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-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Handling multiple domain accounts for accessing a single web app.
> > account_location plugin, then use account_domain and use it as a key in your > access management. > Different templates, same functionality: either switch the stylesheet (CSS) > or go un-DRY by using different view folders for each domain. > The account_location plugin talks about subdomains. Do you know if it's suitable for different top level domains? --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Handling multiple domain accounts for accessing a single web app.
On Thu, Jul 3, 2008 at 6:24 PM, jacob v thomas <[EMAIL PROTECTED]> wrote: > > hi all, > > Here is the question, Is there a way to set multiple domain name for > accessing a single rails application, Bump. Is there a way to handle multiple domains including being able to use different templates for different domains? --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Postgres adapter issues with Rails 2.1: ruby-pg is the answer!
> -- > Building native extensions. This could take a while... > ERROR: Error installing ruby-pg: >ERROR: Failed to build gem native extension. > I had the same problem. I have some additional questions. Why is the "official" postgres gem for rails ruby-pr when it doesn't work on windows at all and doesn't install on linux out of the box? What happened to postgres-pr? Why are there so many gems for postgres and why are so many of them abandoned? Is postgres a second class citizen in rails? --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Exception handling is driving me nuts.
I am utterly unable to control how exceptions are handled in my application and it's driving me nuts The idea is simple. I have a SOAP handler like this. class RtiController < ApplicationController begin wsdl_service_name 'Rti' web_service_scaffold :invoke web_service_api RtiApi before_invocation :authenticate include SoapMethods protected def authenticate (name, args) #the first two arguments are always username and password generic_login(args[0], args[1]) unless logged_in? raise Exceptions::LoginFailedError , "LoginFailedError: Invalid user name or password" end end rescue Exception => e n = e.exception "#{e.inspect}: #{e.message}" n.set_backtrace [] raise n end end Simple right? If any error gets raised either in the authenticate function or any of the functions in the included module I want to catch them and re-raise a new error. The rescue block never gets called no matter where the error happens. Next I try this. def rescue_action do the same thing above end Nope it never gets called either. So I try this rescue_from Exception do |e| n = e.exception "#{e.inspect}: #{e.message}" n.set_backtrace [] raise n end I also tried rescue_from SomeSpecificException and that doesn't work either. I also tried putting a begin rescue block in the included module and that doesn't do anything either. Why is this so complicated? I just want a error handler for this controller. Is actionwebservice messing with the controller or what? P.S. I am using the datanoise actionwebservice. --~--~-~--~~~---~--~~ You received 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---