Ar Chron wrote:
> Pravin Mhatre wrote:
>> Please help me out of this.
> 
> Kind of hard when we have no example from your code...
> 
> What does your controller code look like?

Here is my controller code

def create
    no_of_files = 0
    params_keys = params.keys.size
    for k in 0..params_keys
      no_of_files += 1 if params["SourceFile_#{k}"]
    end
    if no_of_files < 4
      @advert = Advert.find(params[:advert_id])
      for i in 1..no_of_files
        @image = Image.new
        @image.photo = params["SourceFile_" + i.to_s]#.first
        @image.image_type = "Advert"
        @advert.images << @image
      end
      redirect_to advert_path(@advert)
      #render :template => "adverts/show"
    else
      flash[:error] = "You can upload maximum 4 images for an advert."
      redirect_to adverts_path
    end
  end
-- 
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to