Created
April 30, 2012 10:00
-
-
Save Znow/2556957 to your computer and use it in GitHub Desktop.
This file contains 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
Started POST "/admin/tasks" for 127.0.0.1 at 2012-04-30 11:58:53 +0200 | |
Processing by Admin::TasksController#create as JS | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"6Rb8LRbmnOqdSUqQ+xJfyOHinwlLYThvfksXoTicIoQ=", "task"=>{"task_type"=>"Follow-up", "subject"=>"dsadsadsadsa", "responsible"=>"1", "client"=>"3", "deadline"=>"2012-04-30 11:58"}, "commit"=>"Save"} | |
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 | |
Completed 500 Internal Server Error in 2ms | |
ActiveRecord::AssociationTypeMismatch (Client(#70287180650000) expected, got String(#70287161020800)): | |
app/controllers/admin/tasks_controller.rb:25:in `new' | |
app/controllers/admin/tasks_controller.rb:25:in `create' |
This file contains 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
class Task < ActiveRecord::Base | |
attr_accessible :author, :deadline, :responsible, :subject, :task_type, :client | |
belongs_to :client | |
validates :task_type, :subject, :responsible, :deadline, :presence => true | |
end |
This file contains 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
module TaskHelper | |
def task_clients | |
client = Client.all | |
client.map{|c| [c.name, c.id] } | |
end | |
def task_responsibles | |
user = User.all | |
user.map{ |u| [u.name, u.id] } | |
end | |
def task_types | |
['Follow-up', 'Meeting', 'Email', 'Contract', 'Conference call', 'Note'] | |
end | |
end |
This file contains 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 | |
@task = Task.new(params[:task]) | |
@task.merge!(params[:author] => current_user) | |
@client_tasks = @task.client_tasks.create(client.id) | |
respond_to do |format| | |
if @task.save | |
flash[:success] = "<strong>Success!</strong> #{@task.subject} was successfully added.".html_safe | |
end | |
format.js { render :template => "admin/tasks/create.js.erb", | |
:locals => { | |
:task => @task, | |
:redirect_path => admin_tasks_path, | |
} | |
} # create.js.erb | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or: