Wizard with wicked gem - use one page for multiple steps - wicked-gem

How is it possible to use one and the same view for several steps (for example, you have to loop on several questions to answer and the questions should be generated dynamically in the controller via before_action filter)?

Related

sonarqube - creating global widgets

This is similar to questions posted here - How to setup dashboard with all projects view/widget? & here - How to get all projects on a dashboard in multiple columns?
My question is how can we write custom widget that can access list of projects? The sample code for widgets in github is only about ptoject level widgets, whereas I want to create a widget that can be added in the Home Page dashbaord of my sonarqube instance
In order to accomplish this you have to build a plugin, which is going to have that widget. I advice you to take a read at this nice introduction . The widgets are actually a small part of plugins and are written using Ruby on Rails.

In Jekyll, how can I generate year pages?

I'd like to be able to automatically generate by-year archive pages for every year in my blog history. That is, if I have at least one post from 2014, I'd like to be able to generate /archive/2014/index.html, and if I have at least one post from 2013, I'd like it to generate the page /archive/2013/index.html. Is there a way to do that in Jekyll?
Jekyll doesn't provide that feature by default. However, one of the most common plugins is jekyll-archives that is capable to generate post archives by dates, tags, and categories.
However, just keep in mind that this plugin is not supported if you are using GitHub pages as explained here. Actually, in the post itself you can see it is really hard that GitHub will ever support year or categories archives in general.
In case you can't use plugins (for example if you need your site to work on GitHub Pages), you can create one page that contains all years.
This is possible without plugins, for an example see Jekyll/Liquid Templating: How to group blog posts by year?.
If you absolutely must have a separate page for each year and still can't use plugins, there's another way if you're okay with generating a page with two lines of YAML front-matter for each year.
Here's an example where I'm showing how to create tag/category pages (separate page per tag) without using plugins.
It's not that difficult to create something similar for the years of post dates.

UI for dynamically adding multiple values like the LinkedIn skills section in Grails

I have recently started developing web applications using Grails. I just wanted to know how can I convert the multi-selection list provided by Grails scaffolding for many-to-many relations (where you hold Ctrl to add multiple values), to something where I add one value at a time and it has a X to remove the added value and a + to add more. Something similar to the skills section of LinkedIn or the way we add tags in StackOverflow while asking questions.
I would keep the multi-select boxes as they are provided by Grails, but would then use Chosen (a javascript library) to make them nicer.

Ruby Controller Views Actions and Model setup

I have been coding in php for a year now and i have recently decided to start learning Ruby because i heard its a better web language. I'm trying to convert what i have on the website so far into Ruby code, but I'm having trouble understanding the structure for controllers views and models. Heres what i have for php pages.
Homepage(controller)
- index page
- about page
- etc.
Signup(controller)
- index page for signup
Signin(controller)
index page for signin
Admin Page(controller)
Business Page(controller)
Do i make all these controllers and what do the actions and models represent? Is the action the form to signup.
Thanks in advance
I'll try my best to give a condensed answer. RoR follows the MVC pattern (Model, View, Controller) typically controllers handle url requests, models store data and views are used to display the data to the end user. To answer your question, you would not need to create seperate controllers for each individual action. Controllers contain methods for creating, reading, updating, deleting (CRUD) and much more. For example: You might have a UsersController, within this controller are four methods; create, new, update, and delete. This would give you a URL something like /users/new /users/1/edit /users/1/delete
An application like the one you give as an example is quite simple. to seperate an "admin" page is simple and would be something like
<%= if current_user.admin? %>
content only the admin can see
<% end %>
Creating users would involve storing their details in the database, creating a session and allowing users to create and destroy sessions when they login and logout.
The major difference between RoR and PHP (to me, anyway) is PHP makes the views messy by embedding logic code directly into the .html page. Ruby on Rails provides a clean way of seperating logic from html content making it easier to manage or develop between a group.
Pages such as the root page, and about page or contact page might all be methods in the HomeController and would be accesible via /home/index /home/about /home/contact
http://guides.rubyonrails.org/getting_started.html
The above link would be the best place to start learning about the fundamentals.

Rails adding images to a Post

I have a Rails app for blog posts.
Each Post has a title and the blog_text. I want to be able to add images to the blog post as well while i'm creating the blog post. What's the correct way to do this?? Would I just create another migration to add blog_photos so the post has_many blog_photos??
Or should i install a good markdown editor for the blog_text??
It depends on how the images are to be used. Here are two scenarios:
The images are meant to be inside the blog text and added by the user. For this scenario I would use ckeditor (https://github.com/galetahub/ckeditor). This will give the user a WYSIWYG editor and allow them to upload images into the blog text (CKEditor will create two models for attachments).
The images are specific header/icon images for a specific purpose and not contained in the blog text. In this scenario I would use either paperclip (https://github.com/thoughtbot/paperclip) or carrierwave(https://github.com/carrierwaveuploader/carrierwave) and depending on the specific use case would add the image directly to the post model or create a separate model BlogAttachment (if you need a one to many relationship).

Resources