为每个课程添加 图片 ,并且可上传

This commit is contained in:
stormand 2016-11-09 01:08:07 +08:00
parent 29542eb706
commit 26a0bc14eb
14 changed files with 341 additions and 234 deletions

View File

@ -2,8 +2,24 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d7b1c0f9-5303-4042-90a5-05cecbda0e94" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/public/uploads/course/avatar/1/aaa.png" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/assets/javascripts/image.coffee" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/assets/stylesheets/image.scss" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/helpers/image_helper.rb" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/uploaders/avatar_uploader.rb" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/controllers/image_controller_test.rb" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/fixtures/images.yml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/models/image_test.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Gemfile" afterPath="$PROJECT_DIR$/Gemfile" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Gemfile.lock" afterPath="$PROJECT_DIR$/Gemfile.lock" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/controllers/courses_controller.rb" afterPath="$PROJECT_DIR$/app/controllers/courses_controller.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/models/course.rb" afterPath="$PROJECT_DIR$/app/models/course.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/courses/_form.html.erb" afterPath="$PROJECT_DIR$/app/views/courses/_form.html.erb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/courses/detail.erb" afterPath="$PROJECT_DIR$/app/views/courses/detail.erb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/homes/index.html.erb" afterPath="$PROJECT_DIR$/app/views/homes/index.html.erb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/db/schema.rb" afterPath="$PROJECT_DIR$/db/schema.rb" />
</list>
<ignored path="vim.iws" />
<ignored path=".idea/workspace.xml" />
@ -32,21 +48,31 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="detail.erb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/views/courses/detail.erb">
<file leaf-file-name="homes_controller.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/controllers/homes_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288">
<caret line="16" column="41" selection-start-line="16" selection-start-column="41" selection-end-line="16" selection-end-column="41" />
<state relative-caret-position="144">
<caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="schema.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/db/schema.rb">
<file leaf-file-name="20161108164630_add_avatar_to_courses.rb" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="386">
<caret line="66" column="5" selection-start-line="66" selection-start-column="5" selection-end-line="66" selection-end-column="5" />
<state relative-caret-position="90">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="_form.html.erb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/views/courses/_form.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="472">
<caret line="114" column="0" selection-start-line="114" selection-start-column="0" selection-end-line="114" selection-end-column="0" />
<folding />
</state>
</provider>
@ -55,18 +81,48 @@
<file leaf-file-name="courses_controller.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/controllers/courses_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216">
<caret line="12" column="0" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<state relative-caret-position="553">
<caret line="106" column="19" selection-start-line="106" selection-start-column="19" selection-end-line="106" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="homes_controller.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/controllers/homes_controller.rb">
<file leaf-file-name="20160907152104_create_courses.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/db/migrate/20160907152104_create_courses.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72">
<caret line="4" column="10" selection-start-line="4" selection-start-column="10" selection-end-line="4" selection-end-column="10" />
<state relative-caret-position="90">
<caret line="5" column="21" selection-start-line="5" selection-start-column="21" selection-end-line="5" selection-end-column="21" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="course.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/models/course.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="2" column="40" selection-start-line="2" selection-start-column="40" selection-end-line="2" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="edit.html.erb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/views/courses/edit.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="15" column="10" selection-start-line="15" selection-start-column="10" selection-end-line="15" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="detail.erb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/views/courses/detail.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288">
<caret line="16" column="44" selection-start-line="16" selection-start-column="44" selection-end-line="16" selection-end-column="44" />
<folding />
</state>
</provider>
@ -75,38 +131,8 @@
<file leaf-file-name="index.html.erb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/views/homes/index.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="14" column="24" selection-start-line="14" selection-start-column="24" selection-end-line="14" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="course_details.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/fixtures/course_details.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="application_controller.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/controllers/application_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="_form.html.erb" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/views/courses/_form.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="98" column="39" selection-start-line="98" selection-start-column="39" selection-end-line="98" selection-end-column="39" />
<state relative-caret-position="162">
<caret line="9" column="32" selection-start-line="9" selection-start-column="32" selection-end-line="9" selection-end-column="32" />
<folding />
</state>
</provider>
@ -122,16 +148,6 @@
</provider>
</entry>
</file>
<file leaf-file-name="seeds.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/db/seeds.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2214">
<caret line="123" column="253" selection-start-line="123" selection-start-column="253" selection-end-line="123" selection-end-column="253" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="GeneratorOptions">
@ -148,12 +164,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/app/controllers/admins_controller.rb" />
<option value="$PROJECT_DIR$/app/views/admins/index.html.erb" />
<option value="$PROJECT_DIR$/app/models/grade.rb" />
<option value="$PROJECT_DIR$/app/models/user.rb" />
<option value="$PROJECT_DIR$/config/initializers/rails_admin.rb" />
<option value="$PROJECT_DIR$/app/models/course.rb" />
<option value="$PROJECT_DIR$/app/views/teachers/course.html.erb" />
<option value="$PROJECT_DIR$/app/views/users/transcript.html.erb" />
<option value="$PROJECT_DIR$/app/helpers/sessions_helper.rb" />
@ -179,7 +189,6 @@
<option value="$PROJECT_DIR$/app/views/layouts/application.html.erb" />
<option value="$PROJECT_DIR$/.trasvis.yml" />
<option value="$PROJECT_DIR$/config/database.yml" />
<option value="$PROJECT_DIR$/Gemfile" />
<option value="$PROJECT_DIR$/test/controllers/sessions_controller_test.rb" />
<option value="$PROJECT_DIR$/test/controllers/grades_controller_test.rb" />
<option value="$PROJECT_DIR$/test/models/user_test.rb" />
@ -187,7 +196,6 @@
<option value="$PROJECT_DIR$/test/fixtures/users.yml" />
<option value="$PROJECT_DIR$/test/integration/user_login_test.rb" />
<option value="$PROJECT_DIR$/.travis.yml" />
<option value="$PROJECT_DIR$/app/controllers/homes_controller.rb" />
<option value="$PROJECT_DIR$/app/controllers/sessions_controller.rb" />
<option value="$PROJECT_DIR$/db/migrate/20161102035441_create_detail_courses.rb" />
<option value="$PROJECT_DIR$/app/models/detail_course.rb" />
@ -195,10 +203,18 @@
<option value="$PROJECT_DIR$/db/migrate/20161102052958_add_course_introduction_to_courses.rb" />
<option value="$PROJECT_DIR$/db/seeds.rb" />
<option value="$PROJECT_DIR$/db/schema.rb" />
<option value="$PROJECT_DIR$/app/views/courses/detail.erb" />
<option value="$PROJECT_DIR$/db/migrate/20161108155922_drop_image.rb" />
<option value="$PROJECT_DIR$/Gemfile" />
<option value="$PROJECT_DIR$/app/models/image.rb" />
<option value="$PROJECT_DIR$/app/uploaders/image_uploader.rb" />
<option value="$PROJECT_DIR$/app/controllers/image_controller.rb" />
<option value="$PROJECT_DIR$/app/controllers/homes_controller.rb" />
<option value="$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb" />
<option value="$PROJECT_DIR$/app/views/courses/_form.html.erb" />
<option value="$PROJECT_DIR$/app/models/course.rb" />
<option value="$PROJECT_DIR$/app/controllers/courses_controller.rb" />
<option value="$PROJECT_DIR$/app/views/homes/index.html.erb" />
<option value="$PROJECT_DIR$/app/views/courses/_form.html.erb" />
<option value="$PROJECT_DIR$/app/views/courses/detail.erb" />
</list>
</option>
</component>
@ -265,6 +281,38 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="CourseSelect" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="db" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="CourseSelect" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="db" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="migrate" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
@ -283,6 +331,28 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="CourseSelect" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="app" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="views" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="homes" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
@ -305,24 +375,6 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="CourseSelect" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="app" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="models" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="vim" />
@ -588,6 +640,10 @@
<workItem from="1478019546026" duration="46000" />
<workItem from="1478058543638" duration="6709000" />
<workItem from="1478065331526" duration="2775000" />
<workItem from="1478620137437" duration="2132000" />
<workItem from="1478622284611" duration="1604000" />
<workItem from="1478623902569" duration="289000" />
<workItem from="1478624207152" duration="606000" />
</task>
<task id="LOCAL-00001" summary="增加课程介绍,首页轮播的外观搭建">
<created>1478067100340</created>
@ -600,7 +656,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="10825000" />
<option name="totallyTimeSpent" value="15456000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -613,15 +669,15 @@
</component>
<component name="ToolWindowManager">
<frame x="65" y="24" width="1855" height="1056" extended-state="6" />
<editor active="true" />
<editor active="false" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.40099284" sideWeight="0.4858757" order="1" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.41864315" sideWeight="0.4858757" order="1" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3287483" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39889959" sideWeight="0.51373184" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3287483" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.41945288" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3698075" sideWeight="0.49030694" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.35764945" sideWeight="0.49030694" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3513732" sideWeight="0.5141243" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -656,58 +712,6 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/app/views/layouts/_header.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="15" column="36" selection-start-line="15" selection-start-column="36" selection-end-line="15" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/views/layouts/application.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/assets/stylesheets/application.scss">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="10" column="24" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/controllers/users_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="20" column="5" selection-start-line="20" selection-start-column="5" selection-end-line="20" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/screenshot1.png">
<provider selected="true" editor-type-id="images">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/initializers/wrap_parameters.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="13" column="5" selection-start-line="13" selection-start-column="5" selection-end-line="13" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/initializers/will_paginate.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="12" column="3" selection-start-line="12" selection-start-column="3" selection-end-line="12" selection-end-column="3" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/screenshot4.png">
<provider selected="true" editor-type-id="images">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/screenshot3.png">
<provider selected="true" editor-type-id="images">
<state />
@ -795,14 +799,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Gemfile">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="53" column="27" selection-start-line="53" selection-start-column="27" selection-end-line="53" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rvm/gems/ruby-2.2.4/gems/minitest-5.9.0/lib/minitest/test.rb" />
<entry file="file://$USER_HOME$/.rvm/gems/ruby-2.2.4/gems/actionpack-4.2.5.2/lib/action_dispatch/testing/assertions/response.rb" />
<entry file="file://$PROJECT_DIR$/test/integration/user_login_test.rb">
@ -854,22 +850,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20160818081955_create_users.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="10" column="31" selection-start-line="10" selection-start-column="31" selection-end-line="10" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20160909105514_create_grades.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="3" column="26" selection-start-line="3" selection-start-column="6" selection-end-line="3" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/models/grade.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
@ -889,31 +869,32 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="324">
<caret line="18" column="22" selection-start-line="18" selection-start-column="22" selection-end-line="18" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20161102035441_create_detail_courses.rb" />
<entry file="file://$PROJECT_DIR$/app/views/courses/edit.html.erb">
<entry file="file://$PROJECT_DIR$/app/controllers/application_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="15" column="10" selection-start-line="15" selection-start-column="10" selection-end-line="15" selection-end-column="10" />
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/fixtures/course_details.yml" />
<entry file="file://$PROJECT_DIR$/db/migrate/20161108153212_add_attachment_image_to_images.rb" />
<entry file="file://$PROJECT_DIR$/db/migrate/20161108155922_drop_image.rb" />
<entry file="file://$PROJECT_DIR$/db/migrate/20160909105514_create_grades.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="3" column="26" selection-start-line="3" selection-start-column="6" selection-end-line="3" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/models/course.rb">
<entry file="file://$PROJECT_DIR$/db/migrate/20160818081955_create_users.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162">
<caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20160907152104_create_courses.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="360">
<caret line="20" column="0" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
<state relative-caret-position="180">
<caret line="10" column="31" selection-start-line="10" selection-start-column="31" selection-end-line="10" selection-end-column="31" />
<folding />
</state>
</provider>
@ -922,14 +903,41 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2214">
<caret line="123" column="253" selection-start-line="123" selection-start-column="253" selection-end-line="123" selection-end-column="253" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20161108160758_create_images.rb" />
<entry file="file://$PROJECT_DIR$/Gemfile">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="774">
<caret line="43" column="17" selection-start-line="43" selection-start-column="17" selection-end-line="43" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/schema.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="386">
<caret line="66" column="5" selection-start-line="66" selection-start-column="5" selection-end-line="66" selection-end-column="5" />
<state relative-caret-position="900">
<caret line="50" column="4" selection-start-line="50" selection-start-column="4" selection-end-line="50" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/models/image.rb" />
<entry file="file://$PROJECT_DIR$/app/uploaders/image_uploader.rb" />
<entry file="file://$PROJECT_DIR$/app/views/courses/new.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216">
<caret line="12" column="19" selection-start-line="12" selection-start-column="19" selection-end-line="12" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/controllers/image_controller.rb" />
<entry file="file://$PROJECT_DIR$/app/controllers/homes_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
@ -942,58 +950,66 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/views/courses/detail.erb">
<entry file="file://$PROJECT_DIR$/app/models/course.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288">
<caret line="16" column="41" selection-start-line="16" selection-start-column="41" selection-end-line="16" selection-end-column="41" />
<state relative-caret-position="36">
<caret line="2" column="40" selection-start-line="2" selection-start-column="40" selection-end-line="2" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/controllers/application_controller.rb">
<entry file="file://$PROJECT_DIR$/app/views/courses/edit.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/views/homes/index.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="14" column="24" selection-start-line="14" selection-start-column="24" selection-end-line="14" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/fixtures/course_details.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/controllers/homes_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72">
<caret line="4" column="10" selection-start-line="4" selection-start-column="10" selection-end-line="4" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/controllers/courses_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216">
<caret line="12" column="0" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<state relative-caret-position="270">
<caret line="15" column="10" selection-start-line="15" selection-start-column="10" selection-end-line="15" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/views/courses/_form.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="98" column="39" selection-start-line="98" selection-start-column="39" selection-end-line="98" selection-end-column="39" />
<state relative-caret-position="472">
<caret line="114" column="0" selection-start-line="114" selection-start-column="0" selection-end-line="114" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20160907152104_create_courses.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="5" column="21" selection-start-line="5" selection-start-column="21" selection-end-line="5" selection-end-column="21" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/controllers/courses_controller.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="553">
<caret line="106" column="19" selection-start-line="106" selection-start-column="19" selection-end-line="106" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/views/courses/detail.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288">
<caret line="16" column="44" selection-start-line="16" selection-start-column="44" selection-end-line="16" selection-end-column="44" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/views/homes/index.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162">
<caret line="9" column="32" selection-start-line="9" selection-start-column="32" selection-end-line="9" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>

View File

@ -40,6 +40,9 @@ gem 'sdoc', '~> 0.4.0', group: :doc
# for postgresql
gem 'pg', '~> 0.18.4'
gem 'carrierwave'
gem 'mini_magick'
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server

View File

@ -47,6 +47,12 @@ GEM
sass (>= 3.3.4)
builder (3.2.2)
byebug (9.0.5)
carrierwave (0.11.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
mimemagic (>= 0.3.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
@ -87,6 +93,8 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_magick (4.5.1)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
@ -191,10 +199,12 @@ DEPENDENCIES
bcrypt (~> 3.1.11)
bootstrap-sass (~> 3.3.7)
byebug
carrierwave
coffee-rails (~> 4.1.0)
faker (~> 1.6.3)
jbuilder (~> 2.0)
jquery-rails
mini_magick
pg (~> 0.18.4)
rails (= 4.2.5.2)
rails_12factor
@ -207,4 +217,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
1.11.2
1.13.6

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the image controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -1,5 +1,6 @@
class CoursesController < ApplicationController
before_action :student_logged_in, only: [:select, :quit, :list]
before_action :teacher_logged_in, only: [:new, :create, :edit, :destroy, :update]
before_action :logged_in, only: [:index]
@ -104,7 +105,7 @@ class CoursesController < ApplicationController
def course_params
params.require(:course).permit(:course_code, :name, :course_type, :teaching_type, :exam_type,
params.require(:course).permit(:course_code, :avatar, :name, :course_type, :teaching_type, :exam_type,
:credit, :limit_num, :class_room, :course_time, :course_week, :course_introduction)
end

View File

@ -1,5 +1,7 @@
class Course < ActiveRecord::Base
mount_uploader :avatar, AvatarUploader
has_many :grades
has_many :users, through: :grades

View File

@ -0,0 +1,51 @@
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :resize_to_fit => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

View File

@ -102,6 +102,19 @@
</div>
</div>
<div class="form-group">
<%= f.label "图片", class: 'col-sm-3 control-label' %>
<div class="col-sm-9">
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-arrow-right"></span></div>
<%= f.file_field :avatar %>
<%= f.hidden_field :avatar_cache %>
</div>
</div>
</div>
<%= f.submit '提交', class: "btn btn-success btn-block" %>

View File

@ -15,6 +15,7 @@
</div>
<div class="panel-body">
<%= @course.course_introduction %>
<%= image_tag @course.avatar.to_s %>
</div>
</div>
</div>

View File

@ -10,7 +10,7 @@
<div class="carousel-inner">
<div class="item active">
<%= link_to detail_course_path(@course1) do %>
<%= image_tag "profile.png" %><% end %>
<%= image_tag image_tag @course1.avatar.to_s %><% end %>
</div>
<div class="item">
<%= link_to detail_course_path(@course1) do %>
@ -32,7 +32,6 @@
<hr>
<div class="col-sm-10">

View File

@ -0,0 +1,5 @@
class AddAvatarToCourses < ActiveRecord::Migration
def change
add_column :courses, :avatar, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161102052958) do
ActiveRecord::Schema.define(version: 20161108164630) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -32,13 +32,7 @@ ActiveRecord::Schema.define(version: 20161102052958) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "course_introduction"
end
create_table "detail_courses", force: :cascade do |t|
t.integer "course_id"
t.string "course_introduction"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "avatar"
end
create_table "grades", force: :cascade do |t|
@ -52,6 +46,12 @@ ActiveRecord::Schema.define(version: 20161102052958) do
add_index "grades", ["course_id"], name: "index_grades_on_course_id", using: :btree
add_index "grades", ["user_id"], name: "index_grades_on_user_id", using: :btree
create_table "images", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "image"
end
create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB