Allowing admin of rails site to edit html - ruby-on-rails

I have the whole admin backend setup, but I need to add a feature were admins can either edit the HTML of the site, or if easier edit just the text around the site. The main idea is to have the admin edit the form labels through the backend. Was wondering which is the best direction to go with?

I've used Rails internationalization support for things like this in the past: static bits of text that admins, non-technical stakeholders, business people, etc want to tweak and tweak, and I want to enable them to do it quickly (and without bothering me to fix a typo they would)
For the being able to edit form labels you could/should use Rails Internationalization Support for form fields. Here's a super brief intro to this, but there are better documentations to dive into.
Rails Internationalization support allows for more than just storing keys in YAML files - there are few different ways to do it. There's also CopyCopter an open source admin website for internationalization keys.
As far as having non-technical people edit other parts of your site, internationalization could help here too: allowing folks to change whole phrases/blocks of text in your app.
For example, instead of hard coding, "Welcome to the site" in a .html.erb file you do <%= t :welcome %>. An admin can edit the welcome internationalization key and change it to something more appropriate, "Yar! We be welcoming you to the site" if you want to go pirate theme. Or Whatever.
It also gives you internationalization structure for free: makes it easy for admins to edit the English of the site, but you have all the infrastructure for making a French version of the site too - just get a translator to fill in French internationalization values.

Maybe you could realize that with following editor:
Github: https://github.com/jejacks0n/mercury
Demo: http://jejacks0n.github.io/mercury/
Railscasts: http://railscasts.com/episodes/296-mercury-editor (maybe outdated)

Related

Editable area on landing page for site admins

My Rails app has a landing page for visitors with welcome/contact info.
At the moment, this info/html lies in a template.
I want to make it editable for the admins of the application.
What options do I have to accomplish this? Should I create a model with a first_page attribute where I store the html submitted by the admins in a form? Or is there any other way?
You'll need some kind of content management system (CMS). There are lots of ready-made ones for Rails. see http://codecall.net/2014/02/10/best-ruby-on-rails-content-management-systems-cms/
You could just write your own, but you'll end up writing functionality around editing the pages, and then the admins will ask for the ability to upload images etc, and you'll think "gah, wish i'd just used an off the shelf CMS".

Is active Admin a good fit for a complex admin interface for a daily deal rails 3.2 app?

I am building a daily deal app in Rails.
I just installed activeadmin gem which is really great and easy so that I can now create and monitor users. My need for creating and managing deals is quite complex:
I need to be able with the basic text fields (name of deal, date of deals, product name...) to add on the Deal's page stuff that for me (as a Rails newbie), i would associate more with a real CMS than with active admin, that is to say, i must add pictures (through url addresses on amazon S3), embed videos, associate features on certain deals such as vote up or down, and have a sort of html5 WYSIWYG html/text editor allowing me like i'd do on a wordpress site to move/add/arrange/re-position between each others texts, videos, sliders, call to action buttons, videos and much more.
I feel activeadmin is great for basic monitoring and maybe creation of objects for simple cases but as it works so much "automagically" I fear I won't have enough control or ability to bring many features and CMS stuff into active admin that i should build the "Deals admin Interface" on my own pages and not rely on active Admin for this.
What do you think about it ? Can I put all that stuff "inside" my Active Admin pages/controllers...or should I build it "outside" active admin ?
Thanks for your help!
any answer for this question will be subjective..
formally, you can override anything (views, models, controllers) in activeadmin very easily. all this cases have minimal but enough instructions in documentation
there are some difficulties to override look&feel for example with bootstrap to receive more responsive layouts but in general case AA is administration framework designed for generic backends so this feature is not critical
according to your question to manage forms it supports formtastic so you can use any power of this gem
you can override form with generic _form.html.erb in one line with form :partial => "form"
you can use html-editors like this or this or other (like this) out of the box
BUT
this moment always insensibly comes when you begin to understand that some features can be done much better without any gem (not only activeadmin)
the real question is when will you cross this line but it is only up to you..
my advice: try to imagine most difficult issue and implement it with activeadmin. if you solve it with activeadmin - you can try to use it in future. if not => ...
one more thing: you can look at rails-admin - it is very promising and competitive to AA

What is the best conceptual approach, in Rails, to managing content areas in what is otherwise a web application?

(A while back I read this great post: http://aaronlongwell.com/2009/06/the-ruby-on-rails-cms-dilemma.html, discussing the "Rails CMS Dilemma". It describes conceptual approaches to managing content in websites vs web apps. I'm still a beginner with Rails, but had a bit of a PHP background, and I still have trouble wrapping my brain around this.
A lot of what I run into is customers who want a website that is not 100% website, and not 100% web app... That is, perhaps there are several pages of business-to-public facing content, but then there are application elements, and the whole overall look is supposed to be cohesive. This was always fairly simple in PHP, as you just kind of dropped your app code into the PHP "script", etc (though I know there are plenty of cons to this platform and approach).
So I am wondering, what is the best approach in Rails for doing this?
Say you have an application with user authentication and some sort of CRUD stuff going on, where users collaborate on projects or something. Well, what is the optimal approach for managing the text/images of the "How This Site Works" and "Our Company" pages, which people may also want to view? Is it just simply having a pages controller and several text fields, with an admin panel on the back end that lets you edit those fields? Or is it perhaps a common approach to start off with something like Refinery, and then build on top of it for the non-content-driven areas of a site?
Sorry if this is a dumb question. It's just that I've read Hartl's book and others, and they never address this practical low-level stuff for a beginner... Sure, I can build a Twitter feed now, but what Twitter's "About" page (http://twitter.com/about)? I can't just throw text into a view and give that to a client... They want a super easy way to see the site tree, edit content areas, AND administrate/run their Twitter feed or whatever.
Thanks for your help.
I think you're looking for a CMS that runs as a plugin in your Rails application. If that's the case, I'd suggest that you try http://github.com/twg/comfortable-mexican-sofa

Implementing globalization in Rails

While I have experience developing Rails apps in English, I am a blank slate when it comes to handling globalization, so please don't shoot me in the head if my question 'doesn't make sense' :)
I have been asked to add multi language feature to a part of a Rails app that I am working on. Initially its only going to be 2 languages, French and German. The content that will be translated (which is in English now) is rendered using partials at the moment hence I am getting a bit inclined on creating partials with different languages and then based on the users language selection call the relevant partial - Would you recommend this approach?
Although it seems a heavy weight solution for this particular purpose, but I am also looking at the Rails Globalize plugin. This seems to appeal if I look at the long term gains, something like what if later I am asked to translate the entire app.
Any insights on what would be a proper structured approach to handle globalization in Rails?
Many Thanks
Have you had a look at the i18n (internationalization) API that is in Rails itself as of 2.2? It makes it easy to store your language translation files as .yml files, so a fr.yml and a de.yml or whatever. It also steps through different approaches of making languages accessible via browser prefs, or URLs, subdomains, etc. In your HTML template files you use symbols to specify the keys for the string you've translated. At least in my basic usage and testing, it was very easy to work with.
I preffer using translator instead of Rail's i18n, since the former handles "scoping of translation" automatically. I recommend you give it a look.
This is a great article on how to use Ruby's GetText to localise you Rails App.

Ruby on Rails: Editor for backend of the web application

What editor can you suggest to integrate with the backend of the web app I'm currently developing? I want to allow my trusted users to add articles that would be visible on the
frontend. It should have some kind of markup language (to make basic customisation - lists, bold...) and if possible also the option to upload images.
look into restful_authentication (authentication), RedCloth (textile markup language), Hobo (admin interface), and paperclip (file uploads/attachments). You can piece together something with those.
If the editors of your site are not so technical, you might want to look into a Javascript markup editor instead, such as TinyMCE for editing articles - it looks similar to the gmail editor or the one here on S/O (bold / italics / etc), and you don't have to use textile markup.
You can also try routing to, say, admin/modelname, and create administrative controllers there. Hobo might be a way of doing it, but it is usually done manually.
I suggest using RedCloth for adding a textile style mark-up language to your articles.
I also suggest Paperclip for uploading & attaching images to your articles.
Do you mean "editor" in the sense of a component you present to end users in the browser, embedded in the Web page?
Stackoverflow uses the WMD editor. It's good. I'm using it in a current project. It took me about 20 minutes to read the docs and set it up. It's fast, lightweight, works in most browsers, and is easy to use both for you and the end users.
It uses the "Markdown" markup language.
Try Radiant CMS for a complete solution.

Resources