spree_contact_form 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ class ContactController < Spree::BaseController
7
7
 
8
8
  def create
9
9
  @message = Message.new(params[:message] || {})
10
- if @message.valid?
10
+ if @message.save
11
11
  ContactMailer.message_email(@message).deliver
12
12
  flash[:notice] = t('contact_thank_you')
13
13
  redirect_to root_path
@@ -1,21 +1,8 @@
1
- class Message
2
- include ActiveModel::Validations
3
-
4
- attr_accessor :name, :email, :message, :topic_id, :order_number
5
-
1
+ class Message < ActiveRecord::Base
6
2
  validates_presence_of :name, :message, :topic_id
7
3
 
8
4
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
9
5
  validates_format_of :order_number, :with => /(^$)|(^R\d{9}$)/i, :message => I18n.t("invalid_order_number")
10
-
11
-
12
- def initialize(attributes={})
13
- attributes.each do |attr, val|
14
- send("#{attr}=", val)
15
- end
16
- end
17
-
18
- def topic
19
- @topic ||= ContactTopic.find(topic_id)
20
- end
6
+
7
+ belongs_to :topic, :class_name => 'ContactTopic'
21
8
  end
@@ -0,0 +1,17 @@
1
+ class CreateMessages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :messages do |t|
4
+ t.belongs_to :topic
5
+ t.string :name, :null => false
6
+ t.string :email, :null => false
7
+ t.string :order_number
8
+ t.text :message, :null => false
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table :messages
16
+ end
17
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_contact_form
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 3
10
- version: 3.0.3
9
+ - 4
10
+ version: 3.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Nussbaum
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-06 00:00:00 -05:00
18
+ date: 2011-04-13 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -49,6 +49,7 @@ files:
49
49
  - lib/spree_contact_form/engine.rb
50
50
  - lib/generators/spree_contact_form/install_generator.rb
51
51
  - lib/generators/templates/db/migrate/20101122153512_create_contact_topics.rb
52
+ - lib/generators/templates/db/migrate/20101122153513_create_messages.rb
52
53
  - app/views/contact_mailer/message_email.text.erb
53
54
  - app/views/contact/show.html.erb
54
55
  - app/views/admin/contact_topics/edit.html.erb