Last active
December 25, 2015 13:59
-
-
Save thomasstr/6988172 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= f.input :date_today, :collection => [['2 dager siden', Date.today-2], ['I går', Date.yesterday], ['I dag', Date.today.day]], :as :radio_buttons %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Processing by RegisterhoursController#update as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"h9Osn/4grRfQgkOetgx7ZFsTZ2ZkeKZvQIoWdk0CHwQ=", "registerhour"=>{"project_id"=>"47", "timetype"=>"Ordinær", "date_today"=>"15.10.13", "admin_id"=>"1", "from(1i)"=>"2000", "from(2i)"=>"1", "from(3i)"=>"1", "from(4i)"=>"07", "from(5i)"=>"00", "to(1i)"=>"2000", "to(2i)"=>"1", "to(3i)"=>"1", "to(4i)"=>"11", "to(5i)"=>"00", "notes"=>""}, "commit"=>"Oppdater", "id"=>"77"} | |
Admin Load (0.3ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 ORDER BY "admins"."id" ASC LIMIT 1 | |
Registerhour Load (0.1ms) SELECT "registerhours".* FROM "registerhours" WHERE "registerhours"."id" = ? ORDER BY created_at DESC LIMIT 1 [["id", "77"]] | |
(0.1ms) begin transaction | |
Project Load (0.1ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = ? ORDER BY "projects"."id" ASC LIMIT 1 [["id", 47]] | |
SQL (0.3ms) UPDATE "registerhours" SET "date_today" = ?, "updated_at" = ? WHERE "registerhours"."id" = 77 [["date_today", Sun, 13 Oct 0015], ["updated_at", Tue, 15 Oct 2013 07:57:29 UTC +00:00]] | |
(1.3ms) commit transaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@registerhour = Registerhour.new(registerhour_params) | |
#@registerhour.date_today = Date.today | |
respond_to do |format| | |
if Registerhour.exists?(project_id: @registerhour.project_id, timetype: @registerhour.timetype, date_today: Date.today, admin_id: current_admin.id, from: @[email protected], to: @[email protected]) == 1 | |
flash[:error] = "Timer allerede registrert for dette prosjektet." | |
format.html { redirect_to new_registerhour_path } | |
else | |
if @registerhour.save | |
format.html { redirect_to my_hours_url, notice: 'Timer registrert.' } | |
format.json { render action: 'show', status: :created, location: @registerhour } | |
else | |
format.html { render action: 'new' } | |
format.json { render json: @registerhour.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_registerhour | |
@registerhour = Registerhour.find(params[:id]) | |
#@registerhour = Registerhour.where(:admin_id => current_admin.id) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def registerhour_params | |
params.require(:registerhour).permit(:date_today, :from, :to, :timetype, :notes, :approved, :projects, :project_id, :firstname, :admin_id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment