From fa364883977229155e4572e8c3c5dbf2a1b234c5 Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 12 Oct 2016 12:56:44 +0200 Subject: [PATCH] fixed new project form --- app/controllers/projects_controller.rb | 6 +++--- app/views/projects/_new.html.erb | 10 +--------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 4188d5d9e..bbd6ab229 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -47,14 +47,14 @@ class ProjectsController < ApplicationController def new @project = Project.new - @organizations = current_user.organizations end def create @project = Project.new(project_params) - @project.created_by = current_user + @project.created_by = current_user @project.last_modified_by = current_user - if @project.save + if current_organization.id == project_params[:organization_id].to_i && + @project.save # Create user-project association up = UserProject.new( role: :owner, diff --git a/app/views/projects/_new.html.erb b/app/views/projects/_new.html.erb index 3ed45746c..1f476b610 100644 --- a/app/views/projects/_new.html.erb +++ b/app/views/projects/_new.html.erb @@ -1,15 +1,7 @@
<%= form.text_field :name, label: t("projects.index.modal_new_project.name"), autofocus: true, placeholder: t("projects.index.modal_new_project.name_placeholder") %> -
-
- -
-
-
- <%= form.label t("projects.index.modal_new_project.organization") %> - <%= collection_select(:project, :organization_id, @organizations, :id, :name, {}, { :class => "form-control"} ) %> -
+ <%= hidden_field :project, :organization_id, value: current_organization.id %>