refinerycms
An extendable Ruby on Rails CMS that supports Rails 4.2+
Ruby on Rails CMS that supports Rails 4.1 - Refinery CMS refinery is the most popular ruby on rails cms and supports rails 3.2 and 4.1. it's easy to extend and sticks to 'the rails way' where possible.
Does anyone know how to make multiple layouts in refinery? It doesn't have to be in the user admin I just need to be able to programmatically tell some refinery pages to use one layout and others to use a different one.
thanks.
Source: (StackOverflow)
I want to add an attribute to a model I've created within a Refinery CMS engine. I know I could do the following:
rails generate migration AddPartNumberToProducts part_number:string
- Manually move the migration file from
db/migrate
to vendor/extensions/products/db/migrate
But is there a command to generate the migration into the correct folder in the first place?
Thanks!
Source: (StackOverflow)
I have seen http://railscasts.com/episodes/196-nested-model-form-revised and tried the same doing with my refinery engine, but i am not able to see the nested fields in my form while adding a record from admin section and also I am not getting any errors.
I am unable to figure out what exactly is happening or may be if i am missing any refinery related configuration thing.
I tried this on Rails Console:
Refinery::Extension::Model.nested_attributes_options
=> {:nested_model_name=>{:allow_destroy=>false, :update_only=>false}}
I have 2 models Question and Option, but while submitting form for question with options as nested elements it is giving me Error as below
ActiveModel::MassAssignmentSecurity::Error in Refinery::Papers::Admin::QuestionsController#create
Can't mass-assign protected attributes: refinery_papers_options
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"TqL+r60R05+meVhPBXPPipvL+X3ZNx+3dCwoThFBn/Y=",
"question"=>{"content"=>"
aaaaaaaaaa
", "correct_answers"=>"a",
"refinery_papers_options"=>{"content"=>"asdfghjklkmnv
",
"_destroy"=>"0"}, "position"=>0}, "locale"=>:en}
My Models and view Are:
Question Model:
module Refinery
module Papers
class Question < Refinery::Core::BaseModel
self.table_name = 'refinery_papers_questions'
attr_accessible :content, :correct_answers, :options_attributes, :position
validates :content, :presence => true, :uniqueness => true
has_many :options,
:foreign_key => "refinery_papers_question_id",
:class_name => "Refinery::Papers::Option",
:dependent => :destroy
accepts_nested_attributes_for :options,
:allow_destroy => true
end
end
end
Option Model:
module Refinery
module Papers
class Option < Refinery::Core::BaseModel
self.table_name = 'refinery_papers_options'
attr_accessible :content, :position, :refinery_papers_question_id
validates :content, :presence => true
belongs_to :question,
:class_name => 'Refinery::Papers::Question',
:foreign_key => :refinery_papers_question_id
end
end
end
In views Form for nested fields is like this :
<%= f.fields_for :refinery_papers_options do |option_form| %>
<div class='field'>
<%= option_form.label :content, "Option" %><br/>
<%= option_form.text_area :content, :class => "wymeditor widest" %><br/>
</div>
<div class='field'>
<%= option_form.label :_destroy, "Remove Option" -%>
<%= option_form.check_box :_destroy -%>
</div>
<% end %>
When i tried this on rails console i got this stack
2.0.0p247 :007 > Refinery::Papers::Question.create({"content"=>"
jhsdacnlkS
","correct_answers"=>"a",
:refinery_papers_options => {"content"=>"sjdfgczdj
"}})
ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign
protected attributes: refinery_papers_options from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activemodel-3.2.14/lib/active_model/mass_assignment_security/sanitizer.rb:48:in
process_removed_attributes' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activemodel-3.2.14/lib/active_model/mass_assignment_security/sanitizer.rb:20:in
debug_protected_attribute_removal' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activemodel-3.2.14/lib/active_model/mass_assignment_security/sanitizer.rb:12:in
sanitize' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activemodel-3.2.14/lib/active_model/mass_assignment_security.rb:230:in
sanitize_for_mass_assignment' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activerecord-3.2.14/lib/active_record/attribute_assignment.rb:75:in
assign_attributes' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activerecord-3.2.14/lib/active_record/base.rb:498:in
initialize' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activerecord-3.2.14/lib/active_record/persistence.rb:44:in
new' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/activerecord-3.2.14/lib/active_record/persistence.rb:44:in
create' from (irb):7 from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/railties-3.2.14/lib/rails/commands/console.rb:47:in
start' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/railties-3.2.14/lib/rails/commands/console.rb:8:in
start' from
/home/vivek/.rvm/gems/ruby-2.0.0-p247@refinery/gems/railties-3.2.14/lib/rails/commands.rb:41:in
<top (required)>' from script/rails:6:in
require' from
script/rails:6:in `'
Source: (StackOverflow)
I'm working on developing a refinerycms rails app that was working good locally and now i've moved it to my VPS and I was having issues with images that i uploaded through refinerycms not loading and i've been reading that i needed to upgrade my version of imagemagick. I upgraded from 6.2.8 to 6.7.8. Now the images all load on some pages, but not on the admin side.
What is causing this issue? Here's the stacktrace of the error.
Dragonfly::Shell::CommandFailed (Command failed (convert '/var/www/vhosts/tomstestsite.us/PersonalTrainingKT/public/system/refinery/images/2012/06/03/16_36_48_339_pamLemke_after.jpg' '-resize' '225x255>' '/tmp/dragonfly20120705-7812-1xb3pce') with exit status 127):
dragonfly (0.9.12) lib/dragonfly/shell.rb:29:in `raise_shell_command_failed'
dragonfly (0.9.12) lib/dragonfly/shell.rb:23:in `run'
dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:17:in `convert'
dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:103:in `convert'
dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:27:in `resize'
dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:87:in `thumb'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `call'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `catch'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `block in call_last'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `each'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `call_last'
dragonfly (0.9.12) lib/dragonfly/processor.rb:5:in `process'
dragonfly (0.9.12) lib/dragonfly/job.rb:79:in `apply'
dragonfly (0.9.12) lib/dragonfly/job.rb:253:in `block in apply'
dragonfly (0.9.12) lib/dragonfly/job.rb:253:in `each'
dragonfly (0.9.12) lib/dragonfly/job.rb:253:in `apply'
dragonfly (0.9.12) lib/dragonfly/response.rb:25:in `to_response'
dragonfly (0.9.12) lib/dragonfly/server.rb:43:in `block in call'
dragonfly (0.9.12) lib/dragonfly/server.rb:39:in `catch'
dragonfly (0.9.12) lib/dragonfly/server.rb:39:in `call'
dragonfly (0.9.12) lib/dragonfly/middleware.rb:11:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/application.rb:220:in `call'
railties (3.2.3) lib/rails/railtie/configurable.rb:30:in `method_missing'
passenger (3.0.11) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `block in handle_spawn_application'
passenger (3.0.11) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:219:in `block (2 levels) in spawn_rails_application'
passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:214:in `block in spawn_rails_application'
passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.11) helper-scripts/passenger-spawn-server:99:in `<main>'
UPDATE
I've added the code below to my config/application.rb file as suggested here and it helped some of the files show up, and but i'm still unable to upload a file through the app and part of this stacktrace is shown below.
config/application.rb contains this
initializer 'override-image-magick-paths', :after => 'attach-refinery-images-with-
dragonfly' do
app=Dragonfly[:refinery_images]
app.configure_with(:imagemagick)
app.configure do |c|
c.convert_command = "/usr/local/bin/convert" # defaults to "convert"
c.identify_command = "/usr/local/bin/identify" # defaults to "identify"
end
end
stacktrace
Dragonfly::Shell::CommandFailed (Command failed (identify '/tmp/RackMultipart20120708-20096-4m1k9j') with exit status 127):
dragonfly (0.9.12) lib/dragonfly/shell.rb:29:in `raise_shell_command_failed'
dragonfly (0.9.12) lib/dragonfly/shell.rb:23:in `run'
dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:34:in `raw_identify'
dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:24:in `identify'
dragonfly (0.9.12) lib/dragonfly/image_magick/analyser.rb:44:in `format'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `call'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `catch'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `block in call_last'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `each'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `call_last'
dragonfly (0.9.12) lib/dragonfly/analyser.rb:25:in `analyse'
dragonfly (0.9.12) lib/dragonfly/job.rb:247:in `analyse'
Source: (StackOverflow)
Does anyone have implemented the Rails Bootstrap Navbar in refineryCMS?
I'm having a hard time trying to figure out how to render the dropdown menu.
which should be the right way of accomplish this?
_menu.html.erb
<%
if (roots = local_assigns[:roots] || (collection ||= refinery_menu_pages).roots).present?
dom_id ||= 'menu'
css = [(css || 'menu'), 'clearfix'].flatten.join(' ')
hide_children = Refinery::Core.menu_hide_children if hide_children.nil?
-%>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<nav id='<%= dom_id %>' class='<%= css %> nav'>
<ul class="nav">
<%= render :partial => '/refinery/menu_branch', :collection => roots,
:locals => {
:hide_children => hide_children,
:sibling_count => (roots.length - 1),
:menu_levels => local_assigns[:menu_levels],
:apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
} -%>
</ul>
</nav>
</div>
</div>
</div>
<% end -%>
_menu_branch.html.erb
<%
if !!local_assigns[:apply_css] and (classes = custom_menu_branch_css(local_assigns)).any?
css = "class='#{classes.join(' ')}'".html_safe
end
-%>
<li class="dropdown">
<% if menu_branch.children.present? && menu_branch.ancestors.length < 1 %>
<%= link_to(menu_branch.title, refinery.url_for(menu_branch.url), class: "dropdown-togle", data: { toggle: "dropdown" }) -%>
<% else %>
<%= link_to(menu_branch.title, refinery.url_for(menu_branch.url)) -%>
<% end %>
<% if ( (children = menu_branch.children unless hide_children).present? &&
(!local_assigns[:menu_levels] || menu_branch.ancestors.length < local_assigns[:menu_levels]) ) -%>
<ul class="dropdown-menu">
<%= render :partial => '/refinery/menu_branch', :collection => children,
:locals => {
:apply_css => local_assigns[:apply_css],
:hide_children => !!hide_children,
:menu_levels => local_assigns[:menu_levels]
} -%>
</ul>
</li>
<% end -%>
nav_bar snippet
<%= nav_bar :fixed => :top, :brand => "Fashionable Clicheizr 2.0", :responsive => true do %>
<%= menu_group do %>
<%= menu_item "Home", root_path %>
<%= menu_divider %>
<%= drop_down "Products" do %>
<%= menu_item "Things you can't afford", expensive_products_path %>
<%= menu_item "Things that won't suit you anyway", harem_pants_path %>
<%= menu_item "Things you're not even cool enough to buy anyway", hipster_products_path %>
<% if current_user.lives_in_hackney? %>
<%= menu_item "Bikes", fixed_wheel_bikes_path %>
<% end %>
<% end %>
<%= menu_item "About Us", about_us_path %>
<%= menu_item "Contact", contact_path %>
<% end %>
<%= menu_group :pull => :right do %>
<% if current_user %>
<%= menu_item "Log Out", log_out_path %>
<% else %>
<%= form_for @user, :url => session_path(:user), html => {:class=> "navbar-form pull-right"} do |f| -%>
<p><%= f.text_field :email %></p>
<p><%= f.password_field :password %></p>
<p><%= f.submit "Sign in" %></p>
<% end -%>
<% end %>
<% end %>
<% end %>
Source: (StackOverflow)
Im trying to start my first refinery cms project, and am already having trouble. I am trying to get imagemagick going, and am getting errors. I looked on stackoverflow about changing permissions to my profile, or the directories that have problems, also uninstalling and reinstalling, but so far no luck. I was hoping maybe someone could walk me through fixing this. Thanks so much.
Mac-Pro:local user$ brew install imagemagick
Error: You must `brew link jpeg' before imagemagick can be installed
Mac-Pro:local user$ brew link jpeg
Linking /usr/local/Cellar/jpeg/8d...
Error: Could not symlink file: /usr/local/Cellar/jpeg/8d/bin/wrjpgcom
/usr/local/bin is not writable. You should change its permissions.
Source: (StackOverflow)
I have a refinerycms app with the community blog engine installed on it. I would like to add an image field to the blog_post so that I can choose a main image for the post and have it show in my views.
I've tried adding an image field, no joy. Then I looked at one of my other custom engines with an image field and that uses image_id to link to the main image table, so I tried adding an image_id field instead and the editing the blog_post model to have the same 'belongs_to" line. THe edit page for the blog loads, and the image picker partial works, but when I hit save it looks like nothing is being sent to my table.
One thing that concerns me is when I created my custom engine with the image field, I specified it as the field type image. This appears to have created the image_id field on the back end, and set everything up so I can still reference an image class. Adding an image field to the blog didn't do that, just created a field type called image. When inspecting the tables for my custom engine, there is no field type called image, so somewhere there is some transformation magic that I am not able to recreate.
Currently I have the following code:
Created this migration:
class AddPictureToBlog < ActiveRecord::Migration
def self.up
add_column :blog_posts, :main_image_id, :integer
end
def self.down
remove_column :blog_posts, :main_image_id
end
end
Added this to the blog_post model:
belongs_to :main_image_id, :class_name => 'Image'
and have this on the view:
<%= f.label :main_image_id -%>
<%= render :partial => "/shared/admin/image_picker", :locals => {
:f => f,
:field => :main_image_id,
:image => @blog_post.main_image_id,
:toggle_image_display => false
} %>
The custom engine doesn't even refer to the _id field, so I dont know which links im missing here. Any help would be greatly appreciated. It may not be a refinerycms specific problem at all - I am new at rails so there maybe some basics im missing here.
Thanks!
Source: (StackOverflow)
Is there a Rails gem that adds content management functionality to an existing Rails 4 application, which can be used for an Ember.js front-end via RESTful webservices + JSON?
Source: (StackOverflow)
I'm trying to add an h4 tag to the refinerycms wysiwyg editor. How do i do this? Not finding any documentation on this.
I'm assuming i have to do something with this config var:
config.wymeditor_whitelist_tags = {}
Source: (StackOverflow)
I'm trying to configure RefineryCMS to use Fog for S3 uploads. Here's the error I'm getting:
ArgumentError in Refinery::Admin::ImagesController#create
The following keys are invalid: :url
My configuration in config/initializers/refinery/core.rb:
config.s3_bucket_name = '(mybucket)'
config.s3_access_key_id = '(mykey)'
config.s3_secret_access_key = '(mysecret)'
config.s3_backend = true
Any ideas?
Source: (StackOverflow)
I'm using refinerycms in our site to let the less technical staff update content. Inside the gem, they have a Page class that maps each top level page on the site. I'd like to use the acts_as_taggable gem on this Page class. Now I can add the acts_as_taggle declaration directly to the page.rb file, but then I'd have to maintain a separate git repo to track differences between my version and the official release.
Based on some other questions here on SO I created an initializer and extension like so:
lib/page_extensions.rb:
module Pants
module Extensions
module Page
module ClassMethods
def add_taggable
acts_as_taggable
end
end
def self.included(base)
base.extend(ClassMethods).add_taggable
end
end
end
end
config/initializers/pants.rb
require 'page_extensions'
Page.send :include, Pants::Extensions::Page
app/views/layouts/application.html.erb
...
Tags: <%= @page.tag_list %>
The first time I request a page from the server it correctly outputs all the tags on the page. However, if I hit refresh I instead get a NoMethodError
indicating that tag_list is undefined.
I'm new to rails so perhaps my assumptions are wrong, but I expected that call to Page.send would make a permanent change to the Page class rather than to a specific instance of the class. So how would I get the acts_as_taggable added to the Page class on each request?
Source: (StackOverflow)
I previously never had a problem with Refinery. I was refreshing my knowledge by following along to the tutorial http://railscasts.com/episodes/332-refinery-cms-basics .Then when I created a new app with Refinery CMS, I got this error
Bundler could not find compatible versions for gem "actionmailer":
In Gemfile:
refinerycms (~> 2.1.0) ruby depends on
actionmailer (< 3.3, >= 3.1.3) ruby
rails (= 4.0.0) ruby depends on
actionmailer (4.0.0)
But should not these things be there by default with the CMS? why would there be errors only now?
Source: (StackOverflow)
First i created refinerycms application,
in side my application i can't call my own controller route,actions and view i got error like
undefined local variable or method `contacts_save_contact_path' for #<#<Class:0xafc9338>:0xb5467fc>
Source: (StackOverflow)
Am developing one website for which I have to do user login and registration form for the authentication purpose. My question is can we do this using only refinerycms and if it is possible please tell me how to do this. If it is not possible then please tell me which is the best approach. Am trying to implement user authentication using refinerycms. Am new to refinerycms. Thanks in advance
Source: (StackOverflow)
I have installed a blog engine to refinerycms which is working perfectly.
Now I have generated a migration with some table fields changes (of course not refinerycms or blog tables), but I'm getting an error:
== CreateBlogStructure: migrating ============================================
-- create_table("refinery_blog_posts", {:id=>true})
NOTICE: CREATE TABLE will create implicit sequence "refinery_blog_posts_id_seq1" for serial column "refinery_blog_posts.id"
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: relation "refinery_blog_posts" already exists
: CREATE TABLE "refinery_blog_posts" ("id" serial primary key, "title" character varying(255), "body" text, "draft" boolean, "published_at" timestamp, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Source: (StackOverflow)