修改user_extension
This commit is contained in:
parent
80d901f666
commit
7850a2e6f0
|
@ -60,7 +60,9 @@ class MyController < ApplicationController
|
|||
@user.pref.save
|
||||
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||
set_language_if_valid @user.language
|
||||
@user.update_user_extensions()
|
||||
flash[:notice] = l(:notice_account_updated)
|
||||
|
||||
redirect_to my_account_path
|
||||
return
|
||||
end
|
||||
|
|
|
@ -434,7 +434,18 @@ class UsersController < ApplicationController
|
|||
def user_fanslist
|
||||
|
||||
end
|
||||
|
||||
#william
|
||||
def update_extensions(user_extensions)
|
||||
user_extensions = params[:user_extensions]
|
||||
unless user_extensions.nil?
|
||||
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
|
||||
|
||||
# user_extensions.
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def find_user
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
class UserExtension < ActiveRecord::Base
|
||||
attr_accessible :birthday, :brief_introduction, :fans_num, :finish_project_num, :follow_num, :gender, :good_num, :location, :occupation, :publish_requirement_num, :user_id, :work_experience, :zip_code
|
||||
|
||||
belongs_to :user
|
||||
validate :validate_user
|
||||
|
||||
def validate_user
|
||||
errors.add :user_id, :invalid if user.nil? || !user.active? || User.current != user_id
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
class UserExtensions < ActiveRecord::Base
|
||||
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
|
||||
#this method was used to update the table user_extensions
|
||||
def update_user_extensions(birthday=nil,brief_introduction=nil,
|
||||
gender=nil,location=nil,occupation=nil,work_experience=nil,zip_code=nil)
|
||||
self.birthday = birthday
|
||||
self.brief_introduction = brief_introduction
|
||||
self.gender = gender
|
||||
self.location = location
|
||||
self.occupation = occupation
|
||||
self.work_experience = work_experience
|
||||
self.zip_code = zip_code
|
||||
self.save
|
||||
end
|
||||
|
||||
def get_brief_introduction
|
||||
return self.brief_introduction
|
||||
end
|
||||
end
|
|
@ -72,14 +72,14 @@
|
|||
|
||||
<!--tags-->
|
||||
<div class="user_underline"></div>
|
||||
<div class="user_fans">
|
||||
<!-- <div class="user_fans"> -->
|
||||
<!-- added by william -for tag -->
|
||||
<div class="user_tags">
|
||||
<!-- <div class="user_tags"> -->
|
||||
<div id="tags">
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @user,:object_flag => "1"}%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<!--watch-->
|
||||
<div class="user_underline"></div>
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= f.text_field :lastname, :required => true %>
|
||||
</p>
|
||||
<!--added by liu-->
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= f.text_field :brief_introduction, :required => true %>
|
||||
</p>
|
||||
<p style="width:357px;padding-left: 26px;">
|
||||
<%= f.text_field :mail, :required => true %>
|
||||
</p>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="projects">
|
||||
<% if projects_results.size > 0 %>
|
||||
<hr />
|
||||
<h3><strong>Projects:</strong></h3>
|
||||
<strong>Projects:</strong>
|
||||
<% projects_results.each do |prj| %>
|
||||
<div>
|
||||
<h3><strong><%= l(:label_tags_project_name) %><%= link_to "#{prj.name}",:controller => "projects",:action => "show",:id => prj.id %></strong></h3>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
|
||||
:update => "tags_show",
|
||||
:complete => '$("#put-tag-form-issue").hide();' do |f| %>
|
||||
<%= f.text_field :name ,:id => "name-issue",:size=>"30",:require=>true %>
|
||||
<%= f.text_field :name ,:id => "name-issue",:size=>"30",:require=>true,:maxlength => 25,:minlength=>1 %>
|
||||
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
|
||||
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
|
||||
<%= f.submit "add"%>
|
||||
|
@ -34,8 +34,6 @@
|
|||
<span><%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form', {:focus => 'name'} %></span>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<div id="tags_show">
|
||||
<%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
|
||||
</div>
|
||||
|
@ -43,7 +41,7 @@
|
|||
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
|
||||
:update => "tags_show",
|
||||
:complete => '$("#put-tag-form").hide();' do |f| %>
|
||||
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true%>
|
||||
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => 25,:minlength=>1 %>
|
||||
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
|
||||
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
|
||||
<%= f.submit "add"%>
|
||||
|
|
|
@ -236,3 +236,9 @@ non_working_week_days:
|
|||
show_tags_length:
|
||||
format: int
|
||||
default: 5
|
||||
tags_min_length:
|
||||
format: int
|
||||
default: 1
|
||||
tags_max_length:
|
||||
format: int
|
||||
default: 25
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class CreateUserExtensions < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :user_extensions do |t|
|
||||
t.column :user_id,:integer,:null => false
|
||||
t.column :birthday,:date
|
||||
t.column :brief_introduction,:string
|
||||
t.column :gender,:integer
|
||||
t.column :location,:string
|
||||
t.column :occupation,:string
|
||||
t.column :work_experience,:integer
|
||||
t.column :zip_code,:integer
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :user_extensions
|
||||
end
|
||||
end
|
15
db/schema.rb
15
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130811122119) do
|
||||
ActiveRecord::Schema.define(:version => 20130814084938) do
|
||||
|
||||
create_table "a_user_watchers", :force => true do |t|
|
||||
t.string "name"
|
||||
|
@ -625,6 +625,19 @@ ActiveRecord::Schema.define(:version => 20130811122119) do
|
|||
t.integer "fields_bits", :default => 0
|
||||
end
|
||||
|
||||
create_table "user_extensions", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.date "birthday"
|
||||
t.string "brief_introduction"
|
||||
t.integer "gender"
|
||||
t.string "location"
|
||||
t.string "occupation"
|
||||
t.integer "work_experience"
|
||||
t.integer "zip_code"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "user_preferences", :force => true do |t|
|
||||
t.integer "user_id", :default => 0, :null => false
|
||||
t.text "others"
|
||||
|
|
Loading…
Reference in New Issue