Last active
August 29, 2015 13:56
-
-
Save joelbrewer/8863151 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
NameError in ProjectsController#new | |
uninitialized constant User::Project | |
Extracted source (around line #25): | |
def new | |
@project = current_user.build_project | |
@categories = ProjectCategory.all | |
end | |
Rails.root: /Users/joelbrewer/Development/Repos/tn-business-connection | |
Application Trace | Framework Trace | Full Trace | |
app/controllers/projects_controller.rb:25:in `new' | |
Request | |
Parameters: | |
None | |
Toggle session dump | |
Toggle env dump | |
Response | |
Headers: | |
None |
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 Project < ActiveRecord::Base | |
belongs_to :user | |
validates :user, presence: true | |
validates :company_name, | |
:city, | |
:state, | |
:contact_name, | |
:email_address, | |
:phone_number, | |
:description, | |
:category, | |
:sub_category, | |
:presence => true | |
mount_uploader :business_plan, BusinessPlanUploader | |
mount_uploader :company_image, CompanyImageUploader | |
def location_state_city | |
city.capitalize + ", " + state | |
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
class ProjectsController < ApplicationController | |
before_filter :authenticate_user! | |
before_action :investor_only, only: :index | |
def create | |
@project = current_user.create_project(project_params) | |
if @project.save | |
flash[:success] = "Project created!" | |
redirect_to profile_path | |
else | |
render new_project_path | |
end | |
end | |
def index | |
@search = Project.search(params[:q]) | |
@projects = @search.result | |
end | |
def edit | |
@project = current_user.project | |
end | |
def new | |
@project = current_user.build_project | |
@categories = ProjectCategory.all | |
end | |
def update | |
@project = current_user.project | |
if @project.update_attributes(project_params) | |
flash[:success] = "Project updated" | |
redirect_to profile_path | |
else | |
render 'edit' | |
end | |
end | |
def destroy | |
current_user.project.destroy | |
redirect_to profile_path | |
end | |
private | |
def project_params | |
params.require(:project).permit( | |
:business_plan, | |
:company_image, | |
:city, | |
:state, | |
:company_name, | |
:contact_name, | |
:email_address, | |
:phone_number, | |
:description, | |
:category, | |
:sub_category) | |
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
class User < ActiveRecord::Base | |
#add mailboxer methods | |
acts_as_messageable | |
has_one :subscription | |
has_one :plan, :through => :subscription | |
has_one :project | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable | |
validates :user_type, presence: true | |
validates :username, presence: true | |
validates_uniqueness_of :username | |
def full_name | |
first_name + " " + last_name | |
end | |
#def total_projects | |
# self.projects.count | |
#end | |
def investor? | |
self.user_type == "investor" | |
end | |
def entrepreneur? | |
self.user_type = "entrepreneur" | |
end | |
def name | |
self.id | |
end | |
def initiate_conversation(recipient, subject, body) | |
if conversation_initiations_remaining > 0 | |
self.send_message(recipient, subject, body) | |
self.increment!(:conversations_initiated) | |
else | |
false | |
end | |
end | |
def conversation_initiations_remaining | |
if self.subscription | |
self.subscription.plan.user_conversation_limit - self.conversations_initiated | |
else | |
0 | |
end | |
end | |
def mailboxer_email(object) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment