search for: matthewlaw

Displaying 11 results from an estimated 11 matches for "matthewlaw".

2006 May 19
9
Resize uploaded image file without creating temp file?
Hi, I need to take a single uploaded image file and save three resized versions of it, a thumbnail, normal and large version. I was planning on doing this in my model by having an array of geometry strings and looping through them, each time saving a new image object resized to the correct geometry. I know that file column does similar stuff, but I would prefer to have a separate database row
2006 Jun 07
1
Validating numericality based on related attribute value?
I have a price attribute in my model which I need to validate as a positive number if the attribute price_terms.requires_value is equal to ''Y'', otherwise price can be blank or zero. Price_terms is a select list which my model table belongs_to. How do I do this? - I tried doing this: validates_numericality_of :price, :if => self.price_term.requires_value.upcase ==
2006 Apr 12
1
Doing destructive actions with a GET request
I know that you should always use a POST to perform actions that are destructive. I intend to break this rule and use a GET, but before I do, I''d like to know if there is a better way of doing this:- I have an account edit form for the user to make changes to their profile. They have to be logged-in to do this. The problem is I have a file_column field within the form which is storing
2006 May 07
4
Getting column value from lookup table in HABTM relationship
I have a HABTM relationship between my agents and listings tables. Each listing can have many agents and each agent can have many listings. In the agents_listings table I have a column called ''is_primary_agent'' which denotes if the agent is responsible for the listing - only one agent can be primary. At the moment I use this in my listing_controller''s view
2006 Apr 14
5
state_models plugin and file_column?
I was looking at Kyle Mawell''s extremely nifty-looking StateModels plugin http://www.kylemaxwell.com/articles/2006/02/06/fun-with-single-table-inheritance and before I go down the road with it, I was wondering if anyone has used it with file_column. The way file_column deals with an uploaded file -- by storing it to the filesystem in a path that employs the model name and id --
2006 Jul 25
0
dynamic hostname portion in Email links?
I have some emails which contain links like: ''http://www.myserver.com/verify/1234'' which is fine for the live site, but we develop and allow evaluation on ''development.myserver.com'', so the link should get the new hostname complete with subdomain. At present the mail templates have the links hard-coded in. Is it possible to make this work/is there a better
2006 Jun 14
0
Help validating non-model fields
I am sure this has been answered before, but a search of the interweb didn''t return any solution. I want to create a ''Request for more info'' form which gets Emailed to a site admin. This form will have name, Email and comments fields in the view. Sending the Email is no problem - I duplicated the examples from the agile book . What I can''t figure out is the
2006 May 18
0
file_column - filtering uploaded file type and storing image size?
Sorry, more newby FC questions! I would like to use one file upload field to upload both PDFs and images. The images are in the listing_images table and PDFs are in the listing_pdfs table - both have a one-to-many relationship with listings. How do I do this? For listing_images, I would like to store the width and height of the image so I can produce valid xhtml image tags. I can''t
2006 Apr 14
0
Multi-page forms...again :-(
I am building a listings site which has quite a long process for adding a new listing. I want to avoid saving partially complete listings to the database to save space (and I would have to disable constraints for some of the lookup tables used in the select lists, which is bad). I am thinking that the best option is to build up a listing in the session and save it after the user confirms
2006 Apr 10
3
How to validate optional fieldset which becomes mandatory?
Hi, I am posting here because a re-read of my ''Agile'' book and quick google around didn''t give me any obvious clues, but I apologise if this has already been asked and answered before... I have an ''invoice address'' fieldset in a form which is entirely optional, however, should the user fill any one of the fields then they effectively all become
2006 May 30
1
Can''t read from file field second time around
This piece of code takes an uploaded image and resizes it. It''s a bit nasty at the moment as I am still messing around with it. What I can''t understand is why it works for one iteration but then fails with: zero-length blob not permitted `'' On the line: img = Magick::Image.from_blob(self.image).first I am basically doing this in the controller and it fails on the