[Rails] Re: Iterate HashWithIndifferentAccess

2010-09-22 Thread Pål Bergström
Greg Willits wrote: If you need help with that, give an exampe of the exact data structure you'd be starting with. With the help of sortable_element and :tree set as true (and moving up item 3 before item 1, just as a test) I get a Hash from this list: ul li id=3/li li id=1/li li

[Rails] Re: Re: Iterate HashWithIndifferentAccess

2010-09-22 Thread Pål Bergström
radhames brito wrote: i hash inside a hash i read it list[:outer_value][:deeper_value] and you can do list.each do |key,value| if value.class == 'Hash' puts values for key #{ key} value.each do | key2,value2| puts key: #{key2} and value: #{value2}

[Rails] Iterate HashWithIndifferentAccess

2010-09-21 Thread Pål Bergström
How do I iterate a HashWithIndifferentAccess? I need to set the order using a sortable_element. -- 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

[Rails] Re: sortable_element and new ul

2010-09-21 Thread Pål Bergström
pepe wrote: Not sure what you are asking, but maybe you could check into RJS and 'insert_html'? ul liOne/li liTwo/li liThree/li /ul How do you drag Three so it's placed under One, like: ul liOne ulliThree/li/ul /li liTwo/li /ul -- Posted via http://www.ruby-forum.com/. -- You received this

[Rails] Re: sortable_element and new ul

2010-09-21 Thread Pål Bergström
pepe wrote: I might be wrong, but I think that what you're trying to do will need some manual work. I have never done what you're trying to accomplish but if I were trying to do the same thing I would first think about making One a dropable element. The problem I can see, however, is hat the

[Rails] sortable_element and new ul

2010-09-20 Thread Pål Bergström
I have a sortable_element, as a tree. I works great to add and remove from an existing sub list. But how do you create a new list under one element that doesn't have a sub list before? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the

[Rails] Update_all without callbacks

2010-09-15 Thread Pål Bergström
How do I stop callbacks when using Model.update_all? Or stop it for certain columns? -- 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

[Rails] Re: Update_all without callbacks

2010-09-15 Thread Pål Bergström
Simon wrote: From the API docs for update_all : It does not instantiate the involved models and it does NOT trigger Active Record callbacks Hope this helps! Simon It still seems to run before_save. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are

[Rails] Problem with attr_accessor

2010-09-13 Thread Pål Bergström
I pass a value from controller to model with attr_accessor. before_save works fine but not after_find. What could be wrong? This is what I use in index @test = Test.find(:all) @test.each {|a| a.key = cookies[:thekey]} and this in create, show, edit: @test.key = cookies[:thekey] This is my

[Rails] ri-cal mysql table

2010-09-13 Thread Pål Bergström
Which columns should a ri-cal calendar table in mysql have? -- 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

[Rails] Re: Pass a value from controller to model

2010-09-06 Thread Pål Bergström
Colin Law wrote: @my_key = cookies[:my_key] then access @my_key in the view. If the key is logically an attribute of Test then use your method, if you are just putting it there in order to pass it to the view then it may be more logical to use a separate variable. Thanks but I don't need

[Rails] Re: Pass a value from controller to model

2010-09-05 Thread Pål Bergström
Fernando Perez wrote: It should work. What makes you think it doesn't? And it hasn't to be a column in the database (it isn't)? My solution didn't work. But when you say that it should I know I'm on the right track and that the problem is elsewhere. Thanks. -- Posted via

[Rails] Re: Pass a value from controller to model

2010-09-05 Thread Pål Bergström
Pål Bergström wrote: I'm trying to pass a value from a cookie from the controller into model by using attr_accessor. But it doesn't work and I suspect I do something wrong. Is this on the right path? class Test ActiveRecord::Base attr_accessor :key key .. end class

[Rails] Pass a value from controller to model

2010-09-04 Thread Pål Bergström
I'm trying to pass a value from a cookie from the controller into model by using attr_accessor. But it doesn't work and I suspect I do something wrong. Is this on the right path? class Test ActiveRecord::Base attr_accessor :key key .. end class TestController ApplicationController

[Rails] Re: Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-27 Thread Pål Bergström
Greg Donald wrote: I would just add the functionality to ActiveRecord: Where does the unique aes key comes in, the user cookie? -- 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

[Rails] Rack in Rails

2010-07-27 Thread Pål Bergström
Does Rack come with Rails or do I need to install the gem? -- 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

[Rails] Re: Rack in Rails

2010-07-27 Thread Pål Bergström
Robert Walker wrote: Rack is a dependency of Rails so it will get installed when you install the Rails gems. Also keep in mind certain versions of Rails requires a certain version of Rack. Sometimes even an older one than the current. If in doubt just run: sudo gem install rails How

[Rails] Re: Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-27 Thread Pål Bergström
Dave Aronson wrote: Are you doing this over https, or just plain http? For now just over http. But eventually with ssl. -- 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,

[Rails] Re: Re: Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-27 Thread Pål Bergström
Dave Aronson wrote: For now just over http. But eventually with ssl. Before this goes live? Yes. It doesn't matter. The key in the cookie has nothing to do with the overall security. It's just an extra layer of security for the user, encrypted with aes. E.g. I don't want to see certain

[Rails] Re: Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-27 Thread Pål Bergström
Pål Bergström wrote: Greg Donald wrote: I would just add the functionality to ActiveRecord: Where does the unique aes key comes in, the user cookie? It's a unique user key for use with fast_aes in order to encrypt certain data in the database. -- Posted via http://www.ruby-forum.com

[Rails] Re: Re: Re: Problem with reading cgi cookie

2010-07-26 Thread Pål Bergström
Pål Bergström wrote: req = Rack::Request.new(env) req.cookies() I still have problem. I just want to read a damn cookie. Why doesn't this work? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk

[Rails] Re: Re: Re: Problem with reading cgi cookie

2010-07-26 Thread Pål Bergström
Robert Walker wrote: def create @user = User.new(params[:user]) cookies[:user_name] = david end Sets a :user_name cookie with value david upon creating a user def index @users = User.all @cookie_count = cookies.size @user_name_cookie

[Rails] Re: Re: Re: Problem with reading cgi cookie

2010-07-26 Thread Pål Bergström
Robert Walker wrote: Pål Bergström wrote: I though I had made that clear. You read the cookie value as shown in above index method of the controller then you pass that value to the model object. If you don't know how to pass a variable to a method, then I'd suggest learning something

[Rails] Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-26 Thread Pål Bergström
Greg Donald wrote: 2010/7/26 P�l Bergstr�m li...@ruby-forum.com: params is a type of hash, and Hash has merge. So you can add stuff to the params before passing it to the model, something like: params.merge( :my_cookie = cookies[:my_cookie] ) That I know. I was hoping to do something

[Rails] Setting up a VPS with Nginx, Rails and FTP.

2010-07-22 Thread Pål Bergström
I have a new VPS with Debian 5 where I'm going to move my sites. I have installed Rails and Nginx with Passenger. I'm a single user. How should I setup user, html-root (now in /opt/nginx/html), ftp (with proftpd) so I can do ALL. -- Posted via http://www.ruby-forum.com/. -- You received this

[Rails] Re: Passenger bug?

2010-07-19 Thread Pål Bergström
Pål Bergström wrote: Not sure my original problem with Exception Errno::EPIPE is valid or not. So forget that. I've installed it on Mac OS 10.6 as a local developer server. The installation path is /opt/.. as Macports. However, the server root is located in my home path. I can access

[Rails] Does Nginx with Passenger actually work?

2010-07-19 Thread Pål Bergström
I've followed this tutorial http://www.modrails.com/videos/passenger_nginx.mov. Should't it work? It doesn't on my Mac OS 10.6. The server is up and running but not my rails app. Are there any configurations you have to do that isn't described in the tutorial? Should I add something to the app

[Rails] Re: Does Nginx with Passenger actually work?

2010-07-19 Thread Pål Bergström
Marnen Laibow-Koser wrote: Pål Bergström wrote: And what errors are you getting? The browser can't find the server. Anyway, unless you are using your Mac as a server, why are you running Passenger on it in the first place? Mongrel is perfectly suitable for development. Well why not? 1

[Rails] Re: Re: Does Nginx with Passenger actually work?

2010-07-19 Thread Pål Bergström
Peter De Berdt wrote: On 19 Jul 2010, at 17:05, Pål Bergström wrote: Sounds to me apache isn't running or your vhosts don't resolve. When Passenger fails, you get a Passenger error screen describing the error, it never results in server not found. I run Nginx not Apache. For development

[Rails] Re: Re: Does Nginx with Passenger actually work?

2010-07-19 Thread Pål Bergström
Peter De Berdt wrote: On 19 Jul 2010, at 17:05, Pål Bergström wrote: Woops, instead of Apache not running, it seems nginx isn't running properly. Check it with: ps ax | grep nginx It's running :-) -- Posted via http://www.ruby-forum.com/. -- You received this message because you

[Rails] Re: Re: Re: Does Nginx with Passenger actually work?

2010-07-19 Thread Pål Bergström
Peter De Berdt wrote: On 19 Jul 2010, at 17:25, Pål Bergström wrote: So what did you do then? Point the top root of the nginx server to your Rails' public folder? Good question. :-) I did a mistake. I followed the tutorial at mod_rails. I should have understood that I have to set it up

[Rails] Re: Re: Re: Re: Does Nginx with Passenger actually work?

2010-07-19 Thread Pål Bergström
Peter De Berdt wrote: or set up a local dns server, which would be even better Not sure how. Any suggestions? I've heard of BIND but not sure that's valid for Mac OS 10.6. But sooner or later I have to get a better grip of DNS and DNS servers. -- Posted via http://www.ruby-forum.com/. --

[Rails] Re: Passenger bug?

2010-07-18 Thread Pål Bergström
Pål Bergström wrote: I installed the latest Passenger available for download. With Nginx. On Mac OS 10.6. Anyone who has Passenger with Nginx running well on Mac OS 10.6? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups

[Rails] Passenger bug?

2010-07-17 Thread Pål Bergström
I'm trying to get Nginx and Passenger working. I've installed Nginx through Passenger. When accessing a rails app I get Exception Errno::EPIPE in Passenger RequestHandler. From what I can see this has happened to others. And as I understand it it's a Passenger problem. Why is Phusion sending out

[Rails] Re: Passenger bug?

2010-07-17 Thread Pål Bergström
Jeffrey L. Taylor wrote: You've given precious little to go on. I was hoping it would be a known problem and hence have an answer without too much info. Sometimes, or actually rather often, that is the case. I installed the latest Passenger available for download. With Nginx. On Mac OS

[Rails] Stopping Nginx

2010-07-16 Thread Pål Bergström
I'm trying to get rails running with Nginx. I have Nginx installed using Macports and I can get it running. But I can't stop it. This will not work: alias nginx-stop=sudo launchctl unload /Library/LaunchDaemons/org.macports.nginx.plist I get launchctl: Error unloading: nginx. Using killall

[Rails] Re: Stopping Nginx

2010-07-16 Thread Pål Bergström
David Kahn wrote: Not sure if this will help as I am running nginx in Ubuntu, but it took I run it on my mac but I plan to install it on a VPS with Debian 5 so it's good to know. Did you install it using Passenger or apt? -- Posted via http://www.ruby-forum.com/. -- You received this

[Rails] Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Why doesn't this work in a controller, or in a file in a module in /lib: require 'cgi' cgi = CGI.new test = cgi.cookies[mycookie][0] cgi.cookies doesn't get the cookie. But this cgi script does: require 'cgi' cgi = CGI.new('html4') cookie_name = 'mycookie' val_string =

[Rails] Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Frederick Cheung wrote: s doesn't use CGI anymore as the interface between it and the outside world (it uses rack instead) which probably broke that. Controllers have an instance method called cookies which returns a hash like object containing your cookies. Fred I see. Strange that it

[Rails] Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Frederick Cheung wrote: uses rack How do I read a cookie with rack? Trying to find the answer through Google but witout luck. -- 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

[Rails] Re: Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Peter De Berdt wrote: On 09 Jul 2010, at 13:56, Pål Bergström wrote: This should help: http://github.com/dewind/rack-cookie-monster/blob/master/lib/rack/cookie_monster.rb It did. Just a stupid question :-) How do I use env? -- Posted via http://www.ruby-forum.com/. -- You received

[Rails] Re: Re: Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Peter De Berdt wrote: What do you mean? The environment is passed in with the required call method from the rack middleware. I don't know. I just want to get a cookie value in a script in a file in railsapp/lib. I thought this would do it: req = Rack::Request.new(env) req.cookies() But I

[Rails] Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Peter De Berdt wrote: On 09 Jul 2010, at 14:44, Pål Bergström wrote: Well, to get started with middlewares, it's a good thing to read up on how Rails is using it: http://guides.rails.info/rails_on_rack.html Too much to get into now. And you script (thank you very much for you effort

[Rails] Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
I would just like to get the value of a particular cookie in a file in /lib. Is there any other way without rack? -- 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

[Rails] Re: Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Peter De Berdt wrote: Why are you overcomplicating things so much? Good question. :-) It's so much easier when you have a programmers brain. I don't. Thanks for your suggestion. But how do I get the value of a cookie in the model? -- Posted via http://www.ruby-forum.com/. -- You received

[Rails] Re: Re: Re: Re: Re: Re: Problem with reading cgi cookie

2010-07-09 Thread Pål Bergström
Peter De Berdt wrote: On 09 Jul 2010, at 17:02, Pål Bergström wrote: ... or if you just want to make it a field value: That was smart. Thanks. :-) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk

[Rails] Re: Route not working

2010-02-12 Thread Pål Bergström
and this blog_controller.rb would look like... class Admin::BlogController ApplicationController What about the route and map.resources? -- 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

[Rails] Route not working

2010-02-06 Thread Pål Bergström
I've added a controller 'blog/admin'. When I want to access 'blog/admin/index' it says that the page doesn't exist. It works in my local environment. What am I missing? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby

[Rails] Re: Route not working

2010-02-06 Thread Pål Bergström
Craig White wrote: On Sat, 2010-02-06 at 13:26 +0100, P�l Bergstr�m wrote: when you say that you've added blog/admin, the route and mechanics are unclear. You're right. A better way is to add a /controller/admin/blog_controller.rb. I think I'll do that instead. More in line with what I've

[Rails] Search encrypted data

2009-12-20 Thread Pål Bergström
I encrypt a few fields in a table. How can I search for data in rails and these fields? Can I make a temporary table that is decrypted with original text on the fly, which is destroyed after a search? I encrypt and decrypt in the model, when leaving and fetching data. -- Posted via

[Rails] Re: Post and redirect from a controller

2009-11-11 Thread Pål Bergström
tomh wrote: Is there a way I can redirect a user along with a post? (I've looked at the Net::HTTP stuff, but it appears that just sends the post request and doesn't forward the user with it) Did you get an answer? I wonder the same thing. -- Posted via http://www.ruby-forum.com/.

[Rails] Getting table content via helper

2009-10-29 Thread Pål Bergström
I've made a simple cms. I have a table with page content. In the view I make a call for a helper that get's the data: View: %= content(the_id) % In the application helper: def content(c) @content = Pagecontent.find(c).content end This works great. Any problems with this, like

[Rails] Re: Getting table content via helper

2009-10-29 Thread Pål Bergström
Sijo k g wrote: Hi Pål Bergström My opinion is you can move Pagecontent.find(c) to model and access this from controller. Then just use it in view so to avoid making db call from helper/view even this is simple Sijo I see what you mean. However, that would mean a third set

[Rails] Re: Getting table content via helper

2009-10-29 Thread Pål Bergström
Marnen Laibow-Koser wrote: Put the query in the controller. Assign it to a variable. Use the variable in the view. Just as simple. No helper necessary. No breaking MVC. Will mean extra coding for each page. -- Posted via http://www.ruby-forum.com/.

[Rails] Re: Getting table content via helper

2009-10-29 Thread Pål Bergström
Marnen Laibow-Koser wrote: I don't believe it will, but perhaps I don't understand the structure of your app. Can you explain how you're using this? Anyway, even if it *does* mean extra coding, it's the right thing to do. Let's say I have 5 pages. Each page can have 1 or more areas

[Rails] Re: Getting table content via helper

2009-10-29 Thread Pål Bergström
Marnen Laibow-Koser wrote: Then the best thing to do, it seems to me, is to restructure things as I indicated before. Moving the query into the controller will not require any more code, and it will decouple the view from the DB (which is the right thing). The proper Railsy way is like

[Rails] Re: Reflections on Site5 and Eleven2 for Rails

2009-10-27 Thread Pål Bergström
Pål Bergström wrote: Rodney wrote: Any other suggestions of hosts that have speed in both bandwidth and support? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby

[Rails] Stop outside access to directory

2009-10-26 Thread Pål Bergström
How could I stop access to a directory from the outside, for example a dir with images, and only allow it via the Rails app? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[Rails] Re: Reflections on Site5 and Eleven2 for Rails

2009-10-26 Thread Pål Bergström
Rodney wrote: Good to see you guys. I am the owners of Eleven2 here - and just wanted to let u guys know we are stepping up our ruby game and would love to hear your suggestions on what we can do better and who knows, I might even hook you guys with with some free hosting for some ideas!

[Rails] Re: Change column name in view

2009-10-17 Thread Pål Bergström
Chris Bartlett wrote: HUMAN_ATTRIBUTES = {:email = 'E-post'} def self.human_attribute_name(attr) HUMAN_ATTRIBUTES[attr.to_sym] || super end Note that you can rename more than one column: HUMAN_ATTRIBUTES = {:email = 'E-post', :some_other_column = 'Another name'} Great. Works

[Rails] Reflections on Site5 and Eleven2 for Rails

2009-10-16 Thread Pål Bergström
Site5 gives great support, very fast responses, and they include a lot in their account. But the server is slow and the ftp is painfully slow, often just stops. No matter what client I use, and OS, but the terminal is a bit better. They have the server in the US and I'm in Sweden. Eleven2, have

[Rails] Re: Reflections on Site5 and Eleven2 for Rails

2009-10-16 Thread Pål Bergström
with speedy servers vs speedy service. Servers don't break that often. Trausti 2009/10/16 Pål Bergström rails-mailing-l...@andreas-s.net Very valuable info. Tack. I suspect it's an issue with Site5 then. -- Posted via http://www.ruby-forum.com

[Rails] Re: Reflections on Site5 and Eleven2 for Rails

2009-10-16 Thread Pål Bergström
Aldric Giacomoni wrote: Pål Bergström wrote: Very valuable info. Tack. I suspect it's an issue with Site5 then. I have used site5 for a while; I'll point them to this thread so they can take a look. I've never noticed issues when it came to file transfers. Are you in the US? Could

[Rails] Re: Reflections on Site5 and Eleven2 for Rails

2009-10-16 Thread Pål Bergström
Pål Bergström wrote: Aldric Giacomoni wrote: Could also be depending on the actual server I'm at, and you, if it's full or not. We made a test with the Firewall letting me pass through and that was better. Still a bit slow and sometimes pausing. But no time out error this time. From

[Rails] Re: Create and error_messages

2009-10-16 Thread Pål Bergström
Steve Ross wrote: On Oct 15, 2009, at 10:25 PM, P�l Bergstr�m wrote: Marnen Laibow-Koser wrote: P�l Bergstr�m wrote: I highly recommend using make_resourceful for your controllers. It will make problems like this easier to avoid. What does make_resourceful mean? Type it into

[Rails] Re: Create and error_messages

2009-10-16 Thread Pål Bergström
Pål Bergström wrote: Does it matter, for the error_message_for to be displayed, if I use form_tag or form_for? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby

[Rails] Re: Reflections on Site5 and Eleven2 for Rails

2009-10-16 Thread Pål Bergström
Aldric Giacomoni wrote: Pål Bergström wrote: I tried to send the same folder, with a lot of images in it, to my eleven2 account in the server in London. Wow. Extremely fast. Yes, I'm in the US. Maybe their service is poor for you... Maybe they can fix that :) Yes maybe. But I

[Rails] Change column name in view

2009-10-16 Thread Pål Bergström
How can I change the column name from the db so it's displayed in view in a different way? -- 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

[Rails] Re: Change column name in view

2009-10-16 Thread Pål Bergström
Marnen Laibow-Koser wrote: Pål Bergström wrote: Your question is unclear as stated. Can you provide more context? Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org The column name in the db is 'email'. I would like that to be displayed in Swedish like 'E-post

[Rails] Re: Change column name in view

2009-10-16 Thread Pål Bergström
Marnen Laibow-Koser wrote: Pål Bergström wrote: [...] The column name in the db is 'email'. I would like that to be displayed in Swedish like 'E-post'. And what's your view file like? Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org I mean

[Rails] Rails 2.3.x and production mode

2009-10-15 Thread Pål Bergström
Is it necessary to add ENV['RAILS_ENV'] ||= 'production' in rails 2.3.x environment.rb? It's not there by default anymore. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[Rails] Re: Rails 2.3.x and production mode

2009-10-15 Thread Pål Bergström
Marnen Laibow-Koser wrote: It's only necessary if you can't set environment variables on the system you're running on. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org I see. Thanks. -- Posted via http://www.ruby-forum.com/.

[Rails] Create and error_messages

2009-10-15 Thread Pål Bergström
How should a create look like in order to get error_messages being displayed, going back to new and show the error message? I can't get it working so I must miss something. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message

[Rails] Re: Create and error_messages

2009-10-15 Thread Pål Bergström
Pål Bergström wrote: How should a create look like in order to get error_messages being displayed, going back to new and show the error message? I can't get it working so I must miss something. Could it be that I have to turn off RESTful somewhere? -- Posted via http://www.ruby-forum.com

[Rails] Re: Create and error_messages

2009-10-15 Thread Pål Bergström
Patrick Doyle wrote: 2009/10/15 P�l Bergstr�m rails-mailing-l...@andreas-s.net: I have this view/new % form_tag :action = 'create' do % %= error_messages_for 'customer' % labelFörnamn/label %= text_field :customer, :first_name % labelE-post/label %= text_field :customer, :email

[Rails] Re: Create and error_messages

2009-10-15 Thread Pål Bergström
Marnen Laibow-Koser wrote: Pål Bergström wrote: I highly recommend using make_resourceful for your controllers. It will make problems like this easier to avoid. What does make_resourceful mean? -- Posted via http://www.ruby-forum.com

[Rails] A simple form

2009-10-13 Thread Pål Bergström
I'm a bit confused on how to write a simple form. But not a form_tag and not using RESTful. I would like to be able to design without RESTful design. I've used it a bit but don't see the point. It's complicating things, at least for me. -- Posted via http://www.ruby-forum.com/.

[Rails] Re: A simple form

2009-10-13 Thread Pål Bergström
Colin Law wrote: 2009/10/13 Pål Bergström rails-mailing-l...@andreas-s.net: I'm a bit confused on how to write a simple form. But not a form_tag and not using RESTful. form_tag _is_ the way to do a simple form. What do you want to do that form_tag does not do (or what does it do that you

[Rails] Re: A simple form

2009-10-13 Thread Pål Bergström
Colin Law wrote: 2009/10/13 Pål Bergström rails-mailing-l...@andreas-s.net: What do you mean by not RESTful? What does the above do or not for you that is not what you want? Colin Not sure :-) I thought it was. I guess I'll use a regular form_tag then. -- Posted via http://www.ruby

[Rails] Error on relations

2009-10-09 Thread Pål Bergström
I have a controller and model for both products and baskets. I've set up the belongs_to and has_many. When I'm in a third controller shop I get an error when I try to get the products data via baskets. So asking for item.product.price gives an error. Can I have this kind of relation when I'm in

[Rails] Re: Error on relations

2009-10-09 Thread Pål Bergström
Ilan Berci wrote: Pål Bergström wrote: Controllers have nothing to do with models, although best practices suggests having a controller per model. A controller has visibility into all your models if it needs to.. Please show us your relations that you wrote in your models

[Rails] Re: Error on relations

2009-10-09 Thread Pål Bergström
Ilan Berci wrote: Pål Bergström wrote: that's because you defined baskets as having MANY products.. therefore it's: item.products.each do |product| # more code to deal with each product end hth ilan thanks :-) -- Posted via http://www.ruby-forum.com

[Rails] Custom class

2009-10-06 Thread Pål Bergström
Where do I put a custom class? How do I use it? -- 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

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Leonardo Mateo wrote: 2009/10/6 P�l Bergstr�m rails-mailing-l...@andreas-s.net: Where do I put a custom class? It depends on what is it's purpose but, usually, you'll put them on your models directory. How do I use it? Just like you use every class. -- Leonardo Mateo. There's no

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Sijo kg wrote: Hi Pål Bergström Can you paste the code? Sijo It's just a test code. In the file /lib/random.rb I have: class Random def test test end end In the controller I try to call: @test = Random.test -- Posted via http://www.ruby-forum.com

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Leonardo Mateo wrote: 2009/10/6 Pål Bergström rails-mailing-l...@andreas-s.net: -- Leonardo Mateo. There's no place like ~ I can't make it work. I've put in the lib directory. Do I need to make a require or something? I get an error private method `test' called for Of course you have

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Pål Bergström wrote: I see. I have another solution, a custom Crypto-class, in another app similar to this without a require (as I can see now, was a while ago) and that works. It's also in /lib. Can't understan why that works and now it doesn't. I thought that custom classes in /lib

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Colin Law wrote: 2009/10/6 Pål Bergström rails-mailing-l...@andreas-s.net: If you want to call it like that you must make test a class method rather than an instance method, so it must be def self.test .. Colin Thanks. I don't fully understand but it works. This means you don't need

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Sijo kg wrote: http://railstips.org/2009/5/11/class-and-instance-methods-in-ruby That was great. Thank you. Still not sure about instance and what it means. I've encountered a lot in my Rails life but one of those things that doesn't stick. Probably why I'm a web designer and developer

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Sijo kg wrote: It is not a difficult thing to grasp Just an example Suppose you have a class Fruit.Now an apple and an orange are instances of the class Fruit. So in Ruby it can be created like apple = Fruit.new or orange = Fruit.new Thousands of other examples.You have

[Rails] Re: RESTful design

2009-10-02 Thread Pål Bergström
Robert Walker wrote: I replied to a very similar question a day or two ago. Rails provides namespaced resources for just this sort of need. See the following reply: http://www.ruby-forum.com/topic/196355#new Thank you. However I still not sure I see the benefit from the old way.

[Rails] Re: RESTful design

2009-10-01 Thread Pål Bergström
Brian Hogan wrote: Hope that helps some. It does. Thanks :-) -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email

[Rails] RESTful design

2009-09-30 Thread Pål Bergström
I have difficulties to get into restful thinking, so sorry for a possibly stupid question. How do you deal with a product listing which has one interface for admin and another for customers? It needs more methods than the ones in rest, right? There must be plenty of similar situations which

[Rails] Counting words for visual details

2009-09-28 Thread Pål Bergström
I've made a survey in Rails where I want people to pick three words, characteristics for different personality types, from a list of 30 words for 20 different visual details such as linear, organic, symmetry, etc. I save each answer for each user, with the visual detail in one column and the

[Rails] Spree custom css not working

2009-08-25 Thread Pål Bergström
I followed 2.2 Add the stylesheet to the default layout at http://spreecommerce.com/documentation/customization_tutorial.html#createthecustomstylesheet Doesn't work. The file gets copied over but not the link ... / -- Posted via http://www.ruby-forum.com/.

[Rails] Re: Condition in validation

2009-08-18 Thread Pål Bergström
Billee D. wrote: Unless I am severely mistaken, you can't use :unless as a condition in the validation anyway. It would need to be :if = some_condition, where the some_condition method would return true/false. On Aug 17, 1:22�pm, P�l Bergstr�m rails-mailing-l...@andreas-s.net It worked

[Rails] Re: Display of image name when loading

2009-08-17 Thread Pål Bergström
Marnen Laibow-Koser wrote: Never use what? Alt? If so, then you're in for a lecture. Every img tag, without exception, should have an alt attribute. It can be blank, but it must be there (for many good reasons). In addition, it's required in order to get your HTML to validate to

[Rails] Condition in validation

2009-08-17 Thread Pål Bergström
Is this right? validates_uniqueness_of :email, :message = Email taken, :unless = :email == 'i...@mysite.com' -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails:

[Rails] Re: Condition in validation

2009-08-17 Thread Pål Bergström
Frederick Cheung wrote: On Aug 17, 6:22�pm, P�l Bergstr�m rails-mailing-l...@andreas-s.net wrote: Is this right? validates_uniqueness_of :email, :message = Email taken, :unless = :email == 'i...@mysite.com' no. :unless must be the name of a method that returns whether or not to run the

[Rails] Re: Condition in validation

2009-08-17 Thread Pål Bergström
Frederick Cheung wrote: On Aug 17, 6:33�pm, P�l Bergstr�m rails-mailing-l...@andreas-s.net wrote: Fred How would I write a condition that doesn't check the uniqueness of a mail address if the address is 'i...@mysite.com' you write a method that returns true if the email is that magic

  1   2   >