Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ftorghele/FoodCorp
Browse files Browse the repository at this point in the history
  • Loading branch information
Babsi committed Oct 23, 2012
2 parents 2b309d3 + 5cb51b4 commit 41f07e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/controllers/locations_controller.rb
Expand Up @@ -6,13 +6,13 @@ def new
end

def create
@location = Location.create(params[:location])
@location = Location.new(params[:location])
@location.user_id = current_user.id

if @location.save
redirect_to :root, :notice => I18n.t('current_user_location.create_success')
else
redirect_to :back, :notice => I18n.t('current_user_location.create_fail')
render 'new'
end
end

Expand All @@ -23,7 +23,7 @@ def update
if @location.update_attributes(params[:location]) && @location.update_attributes(:activate => params[:location][:activate] == '1')
redirect_to :root, :notice => I18n.t('current_user_location.update_success')
else
redirect_to :back, :notice => I18n.t('current_user_location.update_fail')
render 'edit'
end
end

Expand Down
12 changes: 12 additions & 0 deletions app/views/locations/_locations_form.html.erb
@@ -1,4 +1,16 @@
<% if @location.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@location.errors.count, "error") %> prohibited this location from being saved:</h2>

<ul>
<% @location.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form_for(@location, :url => url_for([current_user,@location]), :html => { :style => '400px' }) do |l| %>
<%= l.label :street %>
<%= l.text_field :street, { :style => 'margin-left:250px', :placeholder => 'Street' } %><br />
<%= l.label :street_number %>
Expand Down

0 comments on commit 41f07e8

Please sign in to comment.