Giter Site home page Giter Site logo

russellquinn / casein Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spoiledmilk/casein3

544.0 33.0 101.0 692 KB

A lightweight CMS toolkit for Ruby on Rails, based on Bootstrap

Home Page: www.caseincms.com

License: Other

Ruby 68.35% JavaScript 1.68% CSS 0.64% HTML 23.17% SCSS 6.16%

casein's Introduction

Casein - a lightweight CMS toolkit for Ruby on Rails, based on Bootstrap

Casein is a Rails 5.x/6.x gem that provides scaffolding generators and helper functions to quickly create a clean and minimal CRUD interface for your data.

It comes with a pre-rolled user-authentication system, supports user-based timezones, and is mobile ready.

As Casein is completely decoupled from the front end, it can be added to new or existing Rails projects, or used as a standalone CMS to drive platforms built on other technologies.

Screenshots at: www.caseincms.com

Requirements

This version of Casein is designed for Ruby on Rails 5.x/6.x and Ruby 2.4.10 or later.

Casein 5.1.1.5 was the last gem release compatible with Rails 4.x.

What’s New in 5.5.1

  • Suport for Rails 6.1 (fixed deprecated usage of ‘update_attributes`, which was removed completely from Rails 6.1)

What’s New in 5.5.0

  • Updates minimum version of AuthLogic to 6.1 to resolve compatibility with Ruby 2.7

  • Updates minimum version of Ruby to 2.4.10

Installation

— Create a new Rails project (or use an existing one) and enter the project directory from a terminal prompt.

— Add the Casein gem to your Gemfile:

gem 'casein', '~>5.5.1'

— Then use bundler to install Casein and its dependencies:

bundle install

— If you have just created a new project — and don’t want to use the default SQLite settings — then remember to add your database details to /config/database.yml at this point.

— To enable Casein notification emails (used for new users and forgotten passwords) then add your SMTP server information to your initializers. For development, you can use something cool like MailCatcher (mailcatcher.me)

— Install Casein configuration files into your project. This should not be run more than once without backing up or merging the generated files, as your customisations will be overwritten:

rails g casein:install

— Perform a database migration to create the Casein users table:

rake db:create (if needed)
rake db:migrate

— Run the following Rake task to set up an initial user. You should specify your email address and password (or omit the password parameter to have a random password assigned.) If you’ve set up an SMTP server in your Rails environment then you’ll also receive an email notification about the new account.

rake casein:users:create_admin [email protected] [password=your_password]

(square brackets indicate an optional parameter, do not include)

— Run your app! (rebooting the web server if applicable)

— You can access Casein at yourdomain.com/casein or yourdomain.com/admin

Casein should now be running!

Usage

The default Casein install supports user authentication. Users may have a role of either ‘administrator’ or ‘user’. The former is allowed to add, edit and delete other Casein users. The latter is only allowed to edit their own profile.

Casein is a framework allowing you to quickly build up an interface to edit and create new records from your database model. As well as the user support and user interface, there are many configurations and generators to help you along the way.

Scaffolding

Casein has a scaffolding generator to automatically create all the CRUD views and controllers for your project models. This is the fastest way to add Casein support to your project.

The command to run the scaffolding generator is:

rails g casein:scaffold ModelName [field:type, field:type]

(square brackets indicate an optional parameter, do not include)

Where:

  • ModelName – The singular name of your model, e.g. Customer

  • field:type – The name of your database fields and their types, e.g. name:string. The field name must match the name in your migrations and the type must be one of the Rails migration types (string, text, integer, float, decimal, datetime, timestamp, time, date, binary, boolean). Note that you do not have to specify all of the fields in your model, but just the ones that you wish to be editable in Casein.

e.g. a typical scaffolding command might look like:

rails g casein:scaffold Customer name:string age:integer date_of_birth:date has_paid:boolean

By default the scaffold generator expects the model and database migration to already exist. This is because you typically won’t want all of your model attributes to be editable in Casein. So you’d set up your model and migration the usual way, then run the Casein scaffold generator just for the appropriate attributes. However, you can add –create-model-and-migration to the generator to also create these files at the same time.

Command-line options that can be added to the end of the scaffold generate command:

--create-model-and-migration = Also creates a model and migration.
--read-only = Creates scaffolding to view model data only (you will not be able to edit, create, or delete records). This is useful if you want to create a read-only viewer of data that's generated elsewhere.
--no-index = Excludes the index view and does not add the model to the navigation. The _table partial is still generated. This is useful when generating has/belongs relationships.

Once the command has been executed, the generator will:

  • Add a new tab for the model to: app/views/casein/layouts/_tab_navigation.html.erb

  • Create a controller with the name: app/controllers/casein/model_controller.erb

  • Add views for index, new and show to: app/views/casein/model/

  • If you restart and run your application now, you’ll be able to sign in to Casein and directly edit and create new instances of your model data right away!

However, you’ll want to customise your views and side bars and extend your controller to suit your project. The scaffold generator just sets up the defaults for you.

NOTE: Once you start customising the generated scaffolding files, you should be aware that if you run the generator again you should not overwrite the changed files without backing them up first. The generator will warn you each time it finds a file that you’ve customised. If you run the scaffold generator from a new version of Casein, then you should manually merge your backup and the new file. You can of course however, leave your originals untouched.

General Configuration

app/helpers/casein/config_helper.rb

This is the main Casein configuration file that allows you to change things such as the website name, logo, notification email address, dashboard URL, etc. The options are documented within the file.

To change the default page that Casein shows, you should change casein_config_dashboard_url. For example, to just go straight to the index page for a model named Page, you’d use:

def casein_config_dashboard_url
  url_for casein_pages_path
end

views/casein/layouts/_tab_navigation.html.erb

An ERB partial for the the left navigation tabs. Note that using the scaffolding generator will automatically add tabs into this file, but it can also be manually edited and rearranged.

view/casein/layouts/_top_navigation.html.erb

An ERB partial for adding items to the top navigation.

/assets/javascripts/casein/custom.js & /assets/stylesheets/casein/custom.scss

These files are added to your app’s /assets directory. They allow you to add custom JavaScript or CSS to your Casein deployment.

/assets/javascripts/casein/auth_custom.js & /assets/stylesheets/casein/auth_custom.scss

These files are added to your app’s /assets directory. They allow you to add custom JavaScript or CSS to the authentication layout in your Casein deployment.

Customising

Once you have the Casein core installed and configured, and have added support for your models with the scaffolding generator, you’ll want to extend it so that it actually has some functionality for your project!

Rules and conventions

  • Casein extension controllers and helpers should be namespaced to ‘Casein::’

  • Casein extension controllers should derive from Casein::CaseinController and not ApplicationController

  • To set the page title, your controller action should set @casein_page_title. If this is not set, then Casein will use a default created from your project name.

Sidebar

The sidebar in Casein should be used for view specific actions, e.g. “Add user” for users/index, or “Back to list”, “Delete user” for users/show.

To specify the contents of the sidebar, you must add a ‘content_for :sidebar’ block in the relevant view file (index, show, etc.) e.g.:

<%= content_for :sidebar do %>
  <li><%= link_to "#{casein_show_icon('th-list')}Back to list".html_safe, casein_admin_users_path %></li>
<% end %>

The casein_show_icon function will display any icon from the Glyphicon collection (glyphicons.com). Simply enter the short name.

Helper functions

There are several Casein helper functions that are automatically available in any of your Casein extension views.

NOTE: Not all are documented here. Please browse the casein_helper.rb file to see what’s available that is not listed below.

Casein version

Your Rails application may discover what version of Casein it is currently running by calling the function:

casein_get_version_info

This will return an array with the keys ‘major’, ‘minor’, ‘patch’, and ‘build’.

Rake tasks

There are several Casein Rake tasks available to manage users. To see what is available, list all Rake commands using:

rake -T

The Casein Rake tasks are all namespaced with ‘casein:’

Bootstrap

Casein is now based on Bootstrap (getbootstrap.com) and jQuery. Bootstrap offers a wealth of UI components, CSS styles, and JavaScript plugins. See the Bootstrap website for full details.

Changing form elements / other helpers

Casein will insert form elements suitable for the field types you specified in the command line. However, you may wish to customise these, e.g. swap a text field for a password field, swap an integer field for a select dropdown, or swap a date field for a full calendar picker, etc.

You will find the form used for both new and show in a partial named _form.html.erb

All of the standard Rails form helpers are available, but the Casein versions are prefixed with casein_. These versions are styled for the Casein interface and have automatic support for validation error reporting.

casein_text_field form, obj, attribute, options = {}
casein_password_field form, obj, attribute, options = {}
casein_text_area form, obj, attribute, options = {}
casein_text_area_big form, obj, attribute, options = {}
casein_check_box form, obj, attribute, options = {}
casein_check_box_group form, obj, check_boxes = {}
casein_radio_button form, obj, attribute, tag_value, options = {}
casein_radio_button_group form, obj, radio_buttons = {}
casein_select form, obj, attribute, option_tags, options = {}, html_options = {}
casein_time_zone_select form, obj, attribute, option_tags, options = {}
casein_collection_select form, obj, object_name, attribute, collection, value_method, text_method, options = {}
casein_date_select form, obj, attribute, options = {}
casein_time_select form, obj, attribute, options = {}
casein_datetime_select form, obj, attribute, options = {}
casein_file_field form, obj, object_name, attribute, options = {}
casein_hidden_field form, obj, attribute, options = {}

Casein also supports the newer HTML5 form helpers:

casein_color_field form, obj, attribute, options = {}
casein_search_field form, obj, attribute, options = {}
casein_telephone_field form, obj, attribute, options = {}
casein_url_field form, obj, attribute, options = {}
casein_email_field form, obj, attribute, options = {}
casein_date_field form, obj, attribute, options = {}
casein_datetime_field form, obj, attribute, options = {}
casein_datetime_local_field form, obj, attribute, options = {}
casein_month_field form, obj, attribute, options = {}
casein_week_field form, obj, attribute, options = {}
casein_time_field form, obj, attribute, options = {}
casein_number_field form, obj, attribute, options = {}
casein_range_field form, obj, attribute, options = {}

You can even insert custom content directly into the Casein field UI chrome:

casein_custom_field form, obj, attribute, custom_contents, options = {}

For more information on each function, check the app/helpers/casein/casein_helper.rb file within the project. The method parameters are typically the same as the Rails form tag helpers. There are some extra Casein options that can be passed through as part of the options hash:

:casein_label – by default the humanized version of the database field name is used as the label, but this will override it with a string of your choice.
:casein_sublabel — add a smaller, clarrifying label to the right of the main label
:casein_button_label – available in casein_radio_button and casein_check_box. Used to give individual buttons their labels.
:casein_truncate - may be passed into casein_table_cell_link along with a maximum length to automatically truncate strings and suffix with '...'

Changing form layout

A Bootstrap responsive two-column layout is automatically created by the scaffold generator. You can manually edit this to be any Bootstrap grid configuration. See Bootstrap documentation for full details: getbootstrap.com/css/#grid

Using alerts

Casein can display three types of styled alerts: Warning, Notice, and Help.

Warning and Notice are set using Rail’s flash variables. Set flash and flash respectively.

Help is set on a page by adding a content_for block to a view:

<%= content_for :help do %>
  This is some help text. It describes what this page is for in more detail.
<% end %>

Routes

Casein adds the routes for the scaffolded models to the top of your application’s routes.rb file. It also adds default routes for basic Casein functionality after your application’s routes. If you have a catch-all style route defined, then these defaults won’t be run. You can solve this using Rails’ constraint feature and the supplied Casein::RouteConstraint, which will stop your catch-all from matching if the request is for a Casein resource.

e.g.

match ':controller(/:action(/:id(.:format)))', constraints: Casein::RouteConstraint.new

Default Timezone

Every Casein user can set their own timezone via their profile. To change the default timezone for new users, set config.time_zone in your app.

Contributing

If you contribute, please help us flesh out the test suites. Do not include new methods that you cannot test.

To run tests:

rake app:db:migrate app:db:test:prepare
rake spec

Disclaimer

Casein was created and is maintained by Russell Quinn. www.russellquinn.com

Casein is available to use under the terms of the MIT License. See the LICENSE file for more details.

casein's People

Contributors

2metres avatar ayaremchuk avatar brchristian avatar bunnymatic avatar chdorner avatar evgeni-spasov avatar mkunkel avatar russellquinn avatar tkmru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

casein's Issues

Relation "casein_admin_users" does not exist

I've deployed casein to heroku and installed Sendgrid successfully, but when I try to create an admin account, I get the following error:

Running `rake casein:users:create_admin [email protected] password=admin` attached to terminal... up, run.1310
PG::UndefinedTable: ERROR:  relation "casein_admin_users" does not exist
LINE 5:                WHERE a.attrelid = '"casein_admin_users"'::re...
                                      ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
                FROM pg_attribute a LEFT JOIN pg_attrdef d
                  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
               WHERE a.attrelid = '"casein_admin_users"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "casein_admin_users" does not exist
LINE 5:                WHERE a.attrelid = '"casein_admin_users"'::re...
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
                FROM pg_attribute a LEFT JOIN pg_attrdef d
                  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
               WHERE a.attrelid = '"casein_admin_users"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum

/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract_adapter.rb:473:in `block in log'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract_adapter.rb:467:in `log'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `exec_no_cache'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:584:in `execute_and_clear'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:160:in `exec_query'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:733:in `column_definitions'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:186:in `columns'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/attributes.rb:93:in `columns'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/attributes.rb:98:in `columns_hash'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/inheritance.rb:205:in `subclass_from_attributes?'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/inheritance.rb:54:in `new'
/app/vendor/bundle/ruby/2.0.0/gems/casein-5.1.1.5/lib/railties/tasks.rake:13:in `block (3 levels) in <top (required)>'

My Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.2.1'    
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc    
gem 'sass-rails', '~> 5.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'uglifier', '>= 1.3.0'

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'sqlite3'
end

group :production do
    gem 'pg'
    gem 'rails_12factor'
end

gem 'casein', '~>5.1.1'

I'm running Ruby 2.2.2 and Rails 4.2.1 on Arch Linux

Bootstrap 3.1

I just discovered casein and it seems to be very helpful! Just a quick question (because you stated in the README that bootstrap 3.1 support will be released "soon"). Are there any plans on when this will be?

Keep up the great work!

Regards
Benjamin

Bundle install fails

I created a new app and added

gem 'casein', '5.0.0'

to the Gemfile. On running

bundle install

The command crashes with error "No live threads left. Deadlock? (fatal)".

Ruby version 2.0.0p353

Any clue as to what might be going on?

Relax hardcoded custom.css and custom.js paths

It seems to me that it'd be more flexible/extensible to require_tree on app/assets/stylesheets/casein rather than forcing the user to put all of their config (if I'm understanding correctly) into custom.css.

Same goes for the js as well. We're wanting to do heavy customization and I'm wishing I could just add files to the casein/ assets folders as needed.

form-control class forgotten on new casein_form_elements

just upgraded to 5.1.1 and tried the new form_tag. The class "form-control" was forgotten I guess.

fix:
casein/app/helpers/casein/casein_helper.rb Line 290 should be:
form.send(field_helper_method, attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control')))

Or am I doing something wrong?

Creating Admin from GUI

Is there any way to create an admin from the GUI(other than terminal) like in refinery cms? If a web-app is shipped with Casein how the user(without any computer knowledge) can create an admin easily?

Uploading images with carrierwave and casein

I've been using carrierwave to store images with my app, and I wanted to be able to do this with casein. For carrierwave, it requires a file_field but saves the image as a string, and it seems when I save the image, I'm not getting the right POST output.

My parameters were:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx=", "gallery"=>{"name"=>"1", "description"=>"1", "image"=>#<ActionDispatch::Http::UploadedFile:0x007faabca44200 @tempfile=#<Tempfile:/tmp/RackMultipart20140725-5595-15lqbcf>, @original_filename="img.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"gallery[image]\"; filename=\"img.jpg\"\r\nContent-Type: image/jpeg\r\n">, "remote_image_url"=>""}, "commit"=>"Save Image"}

My parameters are now:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx=", "gallery"=>{"name"=>"1", "description"=>"1", "image"=>"img.jpg"}, "commit"=>"Add new gallery"}

When I submit, the error is returned that Image can't be blank - in my model the image presence must be true

unable to add admin user

when i run this command
rake casein:users:create_admin email=[email protected] [password=sagar]
i get this error

[Casein] Created new admin user with username 'admin' and password '5e9b600462df58475e44ac84f476dad2'
rake aborted!
Don't know how to build task '[password=sagar]'

how do i get my preffered password??
and how do i delete an existing admin ?? or edit the details

bootstrap-sass dependency

The bootstrap sass dependency is now 3.3.3 now which is looking for an exact match, I faced version conflict when i am using version 3.3.5.1 in my project. I know it is a silly and small thing to correct , but won't it be good to have the dependency as >= 3.3.3 for bootstrap-sass ? or for any dependency version for that matter ?

This is with latest version of ruby - 2.2.1 and rails 4.2.1 bundler 1.10.5

500 internal error

Rails 4.2.1
Ruby 2.2.0p0
Mac OSX 10.10.3
casein ~>5.1.1

I get the following browser error, when going to http://localhost:3000/casein

500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.

With the following logs within the server logs

=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-06-18 15:30:31] INFO  WEBrick 1.3.1
[2015-06-18 15:30:31] INFO  ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
[2015-06-18 15:30:31] INFO  WEBrick::HTTPServer#start: pid=16170 port=3000


Started GET "/casein" for ::1 at 2015-06-18 15:30:35 -0400
  ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"

ArgumentError (wrong number of arguments (2 for 1)):
  actionpack (4.2.1) lib/action_dispatch/http/request.rb:338:in `parse_query'
  rack (1.6.3) lib/rack/request.rb:191:in `GET'

Any idea what needs to be changed/updated?

edit a model?

Is there any reason you've left out edit from your scaffolding? Seems like you've got the form partials and such. Editing should be an easy add. Is there a reason you've avoided it?

undefined method `with_scope'

I'm getting "undefined method `with_scope'" error when following your install instructions. After running my server and trying to login, i get the error on pressing "login"

Error scrypt.rb:137: [BUG] Segmentation fault, CFUNC :sc_calibrate (ruby 2.1.5p273)

I am trying to create a new user by the command:

rake casein:users:create_admin

it gives an error:

DL is deprecated, please use Fiddle
D:/Ruby215/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:137: [BUG] Segmentation fault
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0037 p:0041 s:0161 e:000160 METHOD D:/Ruby215/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:137
c:0036 p:0046 s:0152 e:000150 METHOD D:/Ruby215/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:111
c:0035 p:0028 s:0147 e:000146 METHOD D:/Ruby215/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:73
c:0034 p:0132 s:0141 e:000140 METHOD D:/Ruby215/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:220
c:0033 p:0050 s:0134 e:000133 METHOD D:/Ruby215/lib/ruby/gems/2.1.0/gems/authlogic-3.4.4/lib/authlogic/crypto_providers/scrypt.rb:52
c:0032 p:0098 s:0130 e:000127 METHOD D:/Ruby215/lib/ruby/gems/2.1.0/gems/authlogic-3.4.4/lib/authlogic/acts_as_authentic/password.rb:240 [FINISH]
c:0031 p:---- s:0124 e:000123 CFUNC  :public_send

I am using Ruby 2.1.5 with Rails 4.2.0 on Windows.

Seems like it is the problem with authlogic gem..

any help?

When I run the command to create an admin, my scrypt 1.2.1 throws a seg fault. Platform is Windows 8 64 bit (RailsInstaller). Not sure if Scrypt's fault? Is 1.2.1 an older version?

rake casein:users:create_admin email=[email protected]
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:137: [BUG] Segmentation fault
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0038 p:---- s:0169 e:000168 CFUNC :sc_calibrate
c:0037 p:0041 s:0162 e:000161 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:137
c:0036 p:0046 s:0153 e:000151 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:111
c:0035 p:0028 s:0148 e:000147 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:73
c:0034 p:0132 s:0142 e:000141 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/scrypt-1.2.1/lib/scrypt.rb:220
c:0033 p:0050 s:0135 e:000134 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/authlogic-3.4.4/lib/authlogic/crypto_providers
/scrypt.rb:52
c:0032 p:0098 s:0131 e:000128 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/authlogic-3.4.4/lib/authlogic/acts_as_authenti
c/password.rb:240 [FINISH]
c:0031 p:---- s:0125 e:000124 CFUNC :public_send
c:0030 p:0016 s:0120 e:000119 METHOD c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.0.4/lib/active_record/attribute
_assignment.rb:42

No edit action for users

Clicking on a user in the Casein>Users admin takes me to http://localhost:3000/casein/admin_users/1 and I get an error:

The action '1' could not be found for Casein::AdminUsersController

Running rake routes lists an action: edit_casein_admin_user GET /casein/admin_users/:id/edit(.:format) casein/admin_users#edit

Casein plugins naming conventions

Hey guys,

I have been using Casein in my last couple of projects and have realized the need of a 'Pages' functionality to allow users create their own pages and present them in the frond end. I have developed such a structure and I am trying to put this together in a rails engine gem that could also be named after 'casein-pages' or sorts.

I was wondering if there are any conventions on the naming and/or any guidelines on developing plugins specifically for Casein.

My respects...

adding new user roles

Hi., how can I add more user roles and limit each role to use specific models?

I'm using Casein 5.0.0 on Rails 4.1.4.

Thx.

Deploying to Heroku?

I've pushed an application using Casein to Heroku, but when I try to add the first user I get an shown here:

 heroku run rake casein:users:create_admin [email protected]
Running `rake casein:users:create_admin [email protected]` attached to terminal... up, run.1950
  Rendered vendor/bundle/ruby/2.0.0/gems/casein-5.0.0.0/app/views/casein/casein_notification/new_user_information.erb (2.1ms)

Sent mail to [email protected] (12.6ms)
rake aborted!
Errno::ECONNREFUSED: Connection refused - connect(2)
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver'
/app/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.1.1/lib/action_mailer/base.rb:527:in `block in deliver_mail'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
/app/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.1.1/lib/action_mailer/base.rb:525:in `deliver_mail'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver'
/app/vendor/bundle/ruby/2.0.0/gems/casein-5.0.0.0/app/models/casein/admin_user.rb:31:in `send_create_notification'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:424:in `block in make_lambda'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:221:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:221:in `block in halting_and_conditional'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/callbacks.rb:306:in `create_record'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/timestamp.rb:57:in `create_record'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/persistence.rb:482:in `create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:215:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/callbacks.rb:302:in `create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/persistence.rb:103:in `save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/validations.rb:51:in `save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/attribute_methods/dirty.rb:21:in `save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:268:in `block (2 levels) in save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:208:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:268:in `block in save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:283:in `rollback_active_record_state!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:267:in `save'
/app/vendor/bundle/ruby/2.0.0/gems/casein-5.0.0.0/lib/railties/tasks.rake:16:in `block (3 levels) in <top (required)>'
Tasks: TOP => casein:users:create_admin

Any ideas how to get around it?

WYSIWYG support with image upload?

I've been using Casein for a while now, and really miss the WYSIWYG editor functionality for text fields. Also, a basic file uploader for the WYSIWYG editor would be great!

Are there any plans on implementing this functionality in the near future?

Cheers,
Vernon

/admin path conflict

According to your routes.rb, the /admin path is fixed and there is no way to define a different one with, let's say, a config attribute.

In my case, the /admin namespace is already taken and, if that /admin redirect wasn't defined, then the /casein would have work perfectly.

Any plan to remove that redirect statement?

Cannot create form with multiple select option

Hello,

I'm testing out Casein for a project, and we are looking to create a has_many relationship (in our current custom form, we are using nested attributes).

I created a casein_select form that looks like this:
<%= casein_select f, f.object, :photos, Photo.all, {multiple: true} %>

However, it looks like the options hash isn't being respect.

Any suggestions for this issue, and for representing has_many polymorphic relationships in general?

Thanks for the help!

while creating new controller via scaffolding array's are not created properly

module Casein
class ArticlesController < Casein::CaseinController

## optional filters for defining usage according to Casein::AdminUser access_levels
# before_filter :needs_admin, :except => [:action1, :action2]
# before_filter :needs_admin_or_current_user, :only => [:action1, :action2]

def index
  @casein_page_title = 'Articles'
    @articles = Article.order(sort_order(:[name)).paginate :page => params[:page]
end

end
and VIEWS as well

<%= casein_table_cell_link article.[name, casein_article_path(article) %> <%= casein_sort_link "[name", :[name %>

ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
~/tenworkspace/my_prod/casein$ rails -v
Rails 4.0.12

Scaffolding question

Hi

With your demo pic, "View recipe" page has "Feed title", "Live preview", "Body". How do I generate Scaffolding like that, could you give me a hint?

thx

Deleting Scaffold feature

Need to be able to delete error scaffold from app. ex: Scaffold generate with a typo or if requirements change and need to delete the scaffold.

Fantastic!

I'm sorry, this isn't a real issue so I'm sorry if the notification is bothersome, but I just had to leave feedback somewhere:

This is fantastic! I'm a bit disappointed I haven't heard much of CaseIn before, because this is literally the best CMS I've ever come across in any language. Minimalistic, and working exactly the way I'd want a CMS to work: Work with the resources I want, not a preset and having to get into a ton of documentation to write a plugin to extend it. Make no assumptions, just let me get started immediately and present me with a "Here's all the fields for whatever resource you wanted to be able to edit".

When writing a site for a client, this is just amazing. No confusion, no settings you didn't ask for, nothing. Not WYSIWYG in What You See Is What You Get but exactly What You Design Is What You Get.

I've made portfolio websites in other CMS' like Refinery, Locomotive, and Comfortable Mexican Sofa; Wordpress and Joomla in PHP; and when I want to add a custom resource like Project, nothing has ever been as simple and straight forward as CaseIn with its generators and simple installation process. I showed it to a friend and it inspired him to get started learning Rails immediately. Less than 3 minutes and a functional back-end was all set up, and I could get started designing the views instead.

I rarely give feedback, and especially not posted as an issue on Github, but I just felt I had to show my appreciation for this somehow.

THANK you! This is truly fantastic.

Casein error: undefined local variable or method

Hi I am trying to use casein to build a simple knowledge base.
I followed the readme instructions and create a scaffold:
rails g casein:scaffold Articles article_title:string article_tags:string article_img:binary article_video:binary article_related:string article_popularity:integer article_feedback:string --create-model-and-migration

undefined local variable or method `casein_articles_index_path' for #<#Class:0x00000102f42308:0x00000101c9e990>

Do you know why I am getting this error?

is this default behavior if not then casein is not generating migration

rails g casein:scaffold Article [name:string, description:string]
create app/controllers/casein/articles_controller.rb
create app/views/casein/articles/index.html.erb
create app/views/casein/articles/show.html.erb
create app/views/casein/articles/new.html.erb
create app/views/casein/articles/_form.html.erb
create app/views/casein/articles/_table.html.erb
casein adding namespace to routes.rb
casein adding articles resources to routes.rb
casein adding articles to left navigation bar
ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
:~/tenworkspace/my_prod/casein$ rails -v
Rails 4.0.12

views overloading

how can we overload the views files like login page ? can we customize it?

ransack and has_and_belongs_to_many

Hi,

I'm trying to incorporate a search feature on a resource index page using Ransack.

I have a language model and a translator model. My ransack search form is located on the translator index page. The search works well for attributes belonging to my translator model. However when trying to return results using a filter on it's associated model (language), the page fails to return any results.

Is there a possible reason for this? I'm using rails helper and the searches work outside of my Casein module.

Models relationship:
Language has_and_belongs_to_many Translators
Translator has_and_belongs_to_many Language
Casein controller:

module Casein
class TranslatorsController < Casein::CaseinController

def index
@casein_page_title = 'Translators'
#ransack search:
@search = Translator.search(params[:q])
@Translators = @search.result.includes(:languages).paginate :page => params[:page]
end

Casein Translator View Page partial for search form:

<%= search_form_for @search do |f| %>
.......

<%= f.label :languages_name, "Languages Spoken: " %> <%= f.select :languages_name_eq, options_from_collection_for_select( Language.all, :id, :name ), include_blank: "no preference" %>
...... <% end %>

partial for table also located on translator view index page:

....
<% @translators.each do |translator| %>

<%= translator.name %>

    <td><% translator.languages.each do |language| %>
      <%= language.name %><br>
      <% end %></td>

    <td class="delete">
        <%= link_to(casein_show_row_icon("trash"), casein_provider_path(provider), :method => :delete, :data => { :confirm => "Are you sure you want to delete this provider?" }) %>
    </td>
</tr>

<% end %>

current_user?

How do we retrieve the current logged in user when implementing activity stream? Thanks.

Most optimum way to extend Casein

Hey guys,

I picked up an ambitious task to create a Pages plugin for casein which I dropped and now picked up again; I have come up with some difficulties, but first things first:
I have created the engine:

  • rails plugin new casein_pages --full
  • I then add s.add_depndency 'rails','~> 4.2.1' and s.add_dependency 'casein','~> 5.1.1' to the gemspec file.
  • I create my model rails g model Page title:string body:text
  • I then try to create the casein CRUD scaffold by issuing:
    rails g casein:scaffold Page title:string body:text which fails epically with
[WARNING] Could not load generator "generators/casein/scaffold/scaffold_generator". Error: uninitialized constant Casein::CaseinHelper.
.../vendor/bundle/ruby/2.2.0/gems/casein-5.1.1.5/lib/generators/casein/scaffold/scaffold_generator.rb:4:in `<class:ScaffoldGenerator>'
.../vendor/bundle/ruby/2.2.0/gems/casein-5.1.1.5/lib/generators/casein/scaffold/scaffold_generator.rb:2:in `<module:Casein>'
.../vendor/bundle/ruby/2.2.0/gems/casein-5.1.1.5/lib/generators/casein/scaffold/scaffold_generator.rb:1:in `<top (required)>'

Now, this clearly implies an error in the loading path, but I tried to require or/and include casein in different parts of my engine with no luck.

The error doesn't seem to go away.

Any suggestions or/and insights please?

Circular dependency

I'm having this error while running bundle install:

Your Gemfile requires gems that depend on each other, creating an infinite loop. Please remove gem 'casein' and try again.

The error started when I added the gem countries to Gemfile.

I think it's a weird bug, because countries and casein have very different dependencies:

Puelos-Macbook:ChataBackend paulo$ gem dependency countries
Gem countries-0.11.4
  currencies (~> 0.4.2)
  i18n_data (~> 0.7.0)
  rspec (>= 3, development)
  yard (>= 0, development)

Puelos-Macbook:ChataBackend paulo$ gem dependency casein
Gem casein-5.0.0.0
  authlogic (= 3.4.2)
  casein (>= 0)
  jquery-rails (>= 0)
  scrypt (= 1.2.1)
  will_paginate (= 3.0.5)

Casein overrides will_paginate?

It appears that Casein overrides the behavior of the will_paginate method. This introduces difficulties into the front-end of sites that want to use Casein for their CMS.

Is there any way to install Casein but still be able to use the default will_paginate behavior on a site's frontend?

Can't disable a casein_select

I'd like to disable a select option in certain conditions. In the past I've successfully used disabled: true like this:

= casein_text_field f, f.object, :field, disabled: true

But the select doesn't seem to work.

= casein_select f, f.object, :field, {test: 1}, disabled: true

This results in a working select drop down.

Is it possible to disable a casein_select field? If so, how should I change my code to work properly?

Casein form file upload issue

i am trying to upload file using casein file helper but inspite of the syntax its giving me error like this

undefined method `to_sym' for {:required=>true}:Hash

i am using this for the fiel field
<%= casein_file_field f, f.object, :image, required: true %>

but <%= f.file_field :image %> is working perfectly fine

what can be the issue ?

`access_levels`? how does one use that?

Hey there

I noticed in the user model, you have the access_level parameter but I don't see it used anywhere.

I added a model and would like non-admin users to be able to edit the model. After updating the before_filter for the controller methods, I'm able to login as the non-admin user and see a link to my model index page, but it continues to redirect to blank.

Any idea what I might be doing wrong? Or if you could add to the docs an example of how the access_levels should be used... I'd really appreciate it.

I was thinking I might just add https://github.com/elabs/pundit to the mix but if the access_level stuff that you have in here works, then I could keep things simpler.

Thanks for any info

For reference, here's the controller mods that I made - pretty simple

module Casein
  class PostsController < Casein::CaseinController

    ## optional filters for defining usage according to Casein::AdminUser access_levels
    # before_filter :needs_admin, :except => [:action1, :action2]
    before_filter :needs_admin_or_current_user, :only => [:index, :show, :new, :edit, :update, :create, :destroy]

    def index
       ...
    end
  end
end

Add a test framework and some tests

I'm starting this issue to start a discussion about testing frameworks and what you, as the owner, would like to see.

If it were me, I'd probably start with rspec 3-ish and build mostly feature level/capybara like specs. Things like:

given there is a casein model in the system
and given there is an admin user in the system
login as an admin
I see the navigation
I click on "model name"
I see the model's index page
I click add new model
I fill out the form
I see that I added a new model.

that alone would be a pretty good test. And if you hit it at a high level, you cover a lot of ground quickly.

Using Rspec would also probably make testing the form helpers and other items pretty straight forward.

How does that sound? Do you prefer some other testing approach/tooling whatever?

Casein form for stored hash

Is it possible to use Casein to add values to a hash using ActiveRecord::Store? I asked this on Stack Overflow as well which has the code I've been trying. Any pointers appreciated.

Thanks for putting Casein together anyway, I'm enjoying working with it.

Sorting throws SQL syntax error

Currently the sorting is managed in Casein::CaseinController#sort_order
This method returns a string in the format:

"column_name sort_direction"
->
"id DESC"

Passing string to ActiveRecord won't escape column names and will result in SQL syntax error in some cases. For example when we have a column called "order":

SELECT * FROM table_name ORDER BY order DESC

This will result in an error on both MySQL and PostgreSQL servers. It needs different escaping for each of those:

mysql
SELECT * FROM table_name ORDER BY `order` DESC

postgresql
SELECT * FROM table_name ORDER BY "order" DESC

That's why it is best to pass the sorting as a hash and let ActiveRecord deal with the query syntax. The Casein::CaseinController#sort_order method will return:

{"column name" => "sorting direction"}
->
{"order" => "DESC"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.