Mam takie dziwny problem, otoz mam tabele ‘images’, model ‘image’, i controllera ‘image’, layout ‘upload.rhtml’.
controller:
def addTempImage
unless session[:user_id].nil?
if request.post?
@tempImage = Image.new(:path => “whatever”,
:name => “whatever”,
:title => params[‘form’][‘title’])
if @tempImage.save
flash[:notice] = "uploaded"
end
render(:action => 'upload')
end
end
end
model:
validates_presence_of :title
upload.rhtml
<%= error_messages_for ‘image’%>
<%= flash[:notice] %>
<%= start_form_tag({:action => ‘addTempImage’}) %>
Add a photo: <%= file_field(‘form’, ‘uploaded_picture’) %>
Title: <%= text_field(‘form’, ‘title’) %>
<%= submit_tag(‘Add file’) %>
<%= end_form_tag %>
Kiedy wysylam formularz pusty, rekord nie dodaje sie do tabeli, jednak nie wyswietla mi bledu dlaczego(powinno wyskoczyc, ze jest puste pole ‘title’).
Ograniczajac do przesylania jedynie zmiennej ‘title’, wogole nie wyswietla mi bledu dodawania do tabeli. Nie bardzo wiem, gdzie jest blad.