https://github.com/takeyuweb/mtrails-example
Movable Type + Ruby on Rails 4 Example
https://github.com/takeyuweb/mtrails-example
Last synced: 10 months ago
JSON representation
Movable Type + Ruby on Rails 4 Example
- Host: GitHub
- URL: https://github.com/takeyuweb/mtrails-example
- Owner: takeyuweb
- Created: 2015-12-23T15:56:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-23T16:33:51.000Z (over 10 years ago)
- Last Synced: 2025-01-22T05:16:16.067Z (over 1 year ago)
- Language: Ruby
- Size: 22.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Movable Type + Ruby on Rails 4 Example
===
## Configuration
config/initializers/mt.rb
```ruby
Rails.application.config.to_prepare do
MT::Object.connection_configuration = {
adapter: 'mysql2',
encoding: 'utf8',
host: 'localhost',
username: 'root',
database: 'mt62',
socket: '/var/lib/mysql/mysql.sock'
}
end
```
OR
```ruby
Rails.application.config.to_prepare do
MT::Object.connection_configuration = :mt
end
```
## Objects
### MT::Entry
```ruby
entry = MT::Entry.first
entry.blog # => #
entry.category # => #
entry.categories # => #, ...]>
entry.entry_title # => "TITLE"
entry.entry_status # => "release"
```
### Query Interface
Active Record defautls.
```ruby
MT::Entry.all
MT::Entry.first
```
### Scope
```ruby
MT::Entry.release
```
### Metadata / Custom Fields
```ruby
entry.meta # => #, ...]>
entry.meta.pluck(:entry_meta_type) # => ["field.data1", "field.data2", "revision"]
```
#### Custom Field Search
```ruby
entry_meta = MT::Entry::Meta.arel_table
cond1 = MT::Entry
.joins(:meta)
.where(
entry_meta[:entry_meta_type].eq('field.data1')
.and(entry_meta[:entry_meta_vchar_idx].in(100..200)))
MT::Entry.release.merge(cond1)
```
### MT::Blog
### MT::Category
### MT::Author