gem rich don't apperas in Active_admin - ruby-on-rails

I installed gem rich in my Rails 4.1.5 project. I'm using Active Admin. In my file of admin I have this line that calls rich:
f.input :content, :as => :rich, :config => { :height => '200px' }, :label => 'Conteúdo'
But when I open Active_admin, the rich don't appears (should appear right below the first field):
My gemfile:
gem 'rich', :git => 'https://github.com/kreativgebiet/rich.git'
In my application.rb I have this lines:
config.assets.prefix = '/lince/assets'
config.relative_url_root = '/lince'
config.action_controller.relative_url_root = '/lince'
When I try without this lines, rich works fine.
Anyone can help me? I can't understand why this not working.
Thanks.

rich has not been updated in years. I recommend you look at other WYSIWYG editors

Related

Brakeman not skipping Gemfile.lock with --skip-files param

I'm adding Brakeman to a Rails product but I'm running into an issue. I want it to ignore my Gemfile and Gemfile.lock but when I run it with a command like
brakeman --skip-files Gemfile.lock,Gemfile
it's still touching the files. We use other systems to monitor our gems, but is it not possible to ignore the gem files completely? I can use a brakeman.ignore file of course but would prefer not to. Thanks for any assistance.
I believe this is the check to which you are referring:
https://github.com/presidentbeef/brakeman/blob/master/lib/brakeman/scanner.rb#L39-L40
Brakeman.notify "Processing gems..."
process_gems
The process_gems function is defined here:
https://github.com/presidentbeef/brakeman/blob/master/lib/brakeman/scanner.rb#L131-L152
#Process Gemfile
def process_gems
gem_files = {}
if #app_tree.exists? "Gemfile"
gem_files[:gemfile] = { :src => parse_ruby(#app_tree.read("Gemfile")), :file => "Gemfile" }
elsif #app_tree.exists? "gems.rb"
gem_files[:gemfile] = { :src => parse_ruby(#app_tree.read("gems.rb")), :file => "gems.rb" }
end
if #app_tree.exists? "Gemfile.lock"
gem_files[:gemlock] = { :src => #app_tree.read("Gemfile.lock"), :file => "Gemfile.lock" }
elsif #app_tree.exists? "gems.locked"
gem_files[:gemlock] = { :src => #app_tree.read("gems.locked"), :file => "gems.locked" }
end
if gem_files[:gemfile] or gem_files[:gemlock]
#processor.process_gems gem_files
end
rescue => e
Brakeman.notify "[Notice] Error while processing Gemfile."
tracker.error e.exception(e.message + "\nWhile processing Gemfile"), e.backtrace
end
The AppTree::exists? function is defined here:
https://github.com/presidentbeef/brakeman/blob/master/lib/brakeman/app_tree.rb#L82-L84
def exists?(path)
File.exist?(File.join(#root, path))
end
The GemProcessor::process_gems function is defined here:
https://github.com/presidentbeef/brakeman/blob/master/lib/brakeman/processors/gem_processor.rb#L11
...lots of code...
I don't see any code that would skip this functionality if a certain switch is provided to brakeman. It also looks like the AppTree::exists? function does not take into account if a file was provided to the --skip-files option.
Unfortunately, I believe the current answer is that you can not ignore the gem files completely.
You could create a PR to do what you want and see if the Brakeman team includes it in the next build:
https://brakemanscanner.org/docs/contributing/
Let us know if you discover a way to solve your problem.

Ruby on Rails : Prawn: Positioning table is not working, getting undefined method 'position='

I am trying to position a table on right side but getting
undefined method 'position='
Here is my sample code:
table data , position: :right do
rows(0).font_style = :bold
cells.style :align => :right
cells.borders = []
end
but as per prawn document http://prawn.majesticseacreature.com/manual.pdf‎ above code should run. Where is the problem?
I just figured it out. The master branch of prawn gem has that fixed.
I added
gem 'prawn', :git => "https://github.com/prawnpdf/prawn.git", :ref => '8028ca0cd2'
instead of
gem 'prawn'
Now its working and the code matches with the manual they provided

How to implement badgeville in ruby on rails

Can anyone tell me how to implement badgeville in ruby on rails?
EDIT:
how can I apply this on ruby on rails?
https://github.com/badgeville/badgeville-ruby
I'm not sure how this particular gem work, but normally it should work with following steps
create a file called 'badgeville.rb' inside app/config/initializers
add the following code to badgeville.rb
BadgevilleBerlin::Config.conf(
:host_name => "http://example.com",
:api_key => MY_API_KEY)
restart
then you should be able to use the following commands inside your
controllers/ models
Ex:
new_site = BadgevilleBerlin::Site.new(
:name => "My Website",
:url => "mydomain.com",
:network_id => MY_NETWORK_ID )
success = new_site.save

How to center table in prawn?

I have created a table in prawn and wanted to pass the :position option by whih is also documented in the manual but it throws off an Method_missing error. It seems like this parameter doesnt exist anymore. How can I center a table in prawn?
I ran into the same error. Installing from master on Github fixed the issue.
# Gemfile
gem 'prawn', git: 'https://github.com/prawnpdf/prawn.git'
Issue thread on Github
Hope this helps
pdf.table tablename,
:border_width => 0,
:font_size => 11,
:position => :center
whether the PDF generation is from a declared class or within the controller
you need to add the following line to your Gemfile
gem 'prawn-table', '~> 0.2.1'
At the time of writing that is the gem version, this will give you access to the table methods such as position
I used it in this example and it worked
def table_items(chart_data, doc)
table = Prawn::Table.new(table_rows(chart_data), doc, {:header => true})
table.row(0).font_style = :bold
table.position = :center
table.draw
end

How exactly DO you integrate ckeditor with Paperclip so it can upload image files?

How do you get http://github.com/galetahub/rails-ckeditor working so you can upload image files? I don't think I'll use the s3 storage...
any help would be appreciated.
Yes you can. I assume that you have paperclip already set up for S3. So you have only edit the picture.rb and attachement_file.rb in you model directory (app/model/ckeditor/) and replace these lines
has_attached_file :data,
:url => "/ckeditor_assets/attachments/:id/:filename",
:path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
with your papeclip version has_attached_file:
has_attached_file :data, :styles => { :content => '575>', :thumb => '80x80#' },
:storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => ":attachment/:id/:style.:extension",
:url => ":s3_domain_url"
That's it. Btw: this is example from Rails 3.
I would follow the README for the rails-ckeditor plugin you mentioned. If you don't need the SWFUpload, you can simply integrate the CKEditor and Paperclip, by writing a custom file uploader and custom file browser, and connect them to the editor by specifying urls and callback functions.
It is always useful to have an example, the author has made an example app. Unfortunately, there are a few errors in it. Consider the following points to make it running
change the following lines in config/environment.rb
config.gem 'paperclip', :version => '2.3.3'
config.gem 'ckeditor', :version => '3.4.1'
delete the file index.html in public
add a root route to config/routes.rb
map.root :controller => "pages"
Rails 4.2.0 solution:
How do you get http://github.com/galetahub/rails-ckeditor working so you can upload image files?
As is, CKEditor allows you to embed existing image URLs, but for CKEditor and Paperclip to work together so you can upload images, you will need ImageMagick. As I understand, it handles uploading the image data, making an image URL reference for the uploaded image data and the embedding of the uploaded image data's URL.
CKEditor
Add gem "ckeditor" to your Gemfile
then run the $ bundle install command.
Add this to /app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require ckeditor/init <--------------- THIS
//= require_tree . <----------------------- ABOVE THIS
per: https://github.com/galetahub/ckeditor#how-to-generate-models-to-store-uploaded-files
Add this to:
/config/routes.rb
I put it before the resources which utilize it
mount Ckeditor::Engine => '/ckeditor'
Using "form_for" and having set up an "Article" model with a title:string and text:text
/app/views/articles/_form.html.erb
<p>
<%= f.label :text %><br>
<%= f.cktext_area :text, rows: 10 %> # <-------- "cktext_area"
</p>
Using "simple_form_for"
<div class="form-group">
<%= f.input :body, :as => :ckeditor, input_html: {:ckeditor => {:toolbar => 'FULL'}}, class: "form-control" %>
</div>
Paperclip
per: https://richonrails.com/articles/getting-started-with-ckeditor
Add gem "paperclip" to your Gemfile and $ bundle install.
Then run the following two commands:
$ rails generate ckeditor:install --orm=active_record --backend=paperclip
and
$ rake db:migrate
ImageMagick
For macOS Sierra:
$ brew install imagemagick
For other ImageMagick install options: https://www.imagemagick.org/script/install-source.php
Use following things it working for me but you should have account on Amazon for s3 storage and correct endpoint you can refer following
code.`gem 'aws-sdk', '~> 2'
gem 'aws-s3'
gem 'aws-sdk-v1'
gem 'paperclip'
class Ckeditor::Picture < Ckeditor::Asset
AWS_CONFIG = YAML.load(ERB.new(File.read("#{Rails.root}/config/aws.yml")).result)[Rails.env]
has_attached_file :data,
s3_credentials: {
access_key_id: AWS_CONFIG['access_key_id'],
secret_access_key: AWS_CONFIG['secret_access_key'],
bucket: AWS_CONFIG['bucket'],
},
s3_host_name: 's3.amazonaws.com',
:s3_endpoint => 's3.amazonaws.com',
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
bucket: AWS_CONFIG['bucket'],
url: ':s3_domain_url',
path: '/:class/:attachment/:id_partition/:style/:filename',
default_url: "/:class/:attachment/:id/:style/:basename.:extension",
default_style: "medium"
validates_attachment_size :data, :less_than => 2.megabytes
validates_attachment_presence :data
def url_content
url(:content)
end
end
`
comment this line require "ckeditor/orm/active_record" from /config/initializers
finally put this line in <%= f.cktext_area :body %> view file.
In addition to Zaparka's response, I had to remove #{Rails.root} as I was getting an unitialized constant error. SO instead I put "/config/s3.yml", and that worked.

Resources