I'm making a RoR app that is going to have a bunch of network diagnostic tools in it, like ping, traceroute, whois, etc. It's an internal company thing. Being that I'm learning Rails, I'd like to create it in that.
So, I'm curious what's the best structure to make this? Would it make sense to have all the tools under one MVC, like 'tools', or to break each one out into their own MVC (i.e., ping_controller & model/ping, traceroute_controller & `model/traceroute', etc.)?
So:
App
|--models
| |--tools (which would just write the `ip`, `tool_type` and `hitcount` to the DB.)
|
|--controllers
| |--tools (which would contain the methods: `ping`, `traceroute`, etc.)
|
|--views
|--tools
|--index.html.erb (which would have the individual form to run a given tool and show results)
Or would it make more sense to break it out more, but still keep the individual tool form elements on the same page and direct them with something like form_for(controller: 'ping', action: 'show'):
App
|--models
| |--ping (which would just write the `ip` and `hitcount` to the DB.)
| |--traceroute (which would just write the `ip` and `hitcount` to the DB.)
|
|--controllers
| |--ping (which would contain the normal CRUD and results)
| |--traceroute (which would contain the normal CRUD and results)
|
|--views
|--tools
|--index.html.erb (which would have the individual form to run a given tool and show results)
What's the "Ruby Way" to do this? I feel like the second option is not very DRY, but I'm still learning... hence my question.
If type is the only difference between each types of tools, I would suggest you to use the first way. If there will be more complex logic/columns differences, I would suggest you to have a look into Single Table Inheritance (STI):
http://samurails.com/tutorial/single-table-inheritance-with-rails-4-part-1/
Related
I have many view in Lotus Notes. What I want to do is I want to show only two view on web. So I'm just thinking using Frameset. I have a frameset with three frame. Below here example of my frameset.
--------------------------------------------------
| [HEADER] |
--------------------------------------------------
| [SIDE BAR MENU] | [CONTENT] |
| | |
| Draft | |
| Completed | |
--------------------------------------------------
I try to find in Internet but not found any example on how to display frameset in web. I'm still new with lotus web so please excuse me.
Also I am upgrading my company Lotus Notes system. Our old developer using "$$ViewTemplate for [viewname]" but it only show one view. I need to display two view in web. Anyone can suggest what else can I use other than this $$ViewTemplate? Any help I appreciate. Thanks!
Although this question is way to broad and lacks any kind of research I will try to push you in the right direction:
First: There is a frameset- design- element in designer... it simply works... just try it... Create it, put a Page or a Form in one of the frames (of course these need to be created before) and select it as default for the web (Properties of database) -> Voila
And second: you can use $$ViewTemplateDefault as a template for any view or just copy the existing one and give it another name like "$$ViewTemplate for OtherView" and it will simply work...
Best practice would not be to use framesets and classic notes web design elements but use more "modern" approaches as XPages (introduces in Domino 8.5 in 2008).
If you need to learn something totally new, then don't learn something that is outdated since more than 10 years...
My SEO-people do not write code. All they love is creating good texts. All they can do is pasting texts do database via some nice forms.
The problem is that sometimes they ask me: we need to put the text into page footer. Wee need to put some other text into page header.
And I just can not edit the code every time SEO-man asks me!
And sometimes the text are not related directly to model. I think you will understand me that it is a bad idea to create footer_block field inside a Car or Person model.
How nice it would if there was a gem that could:
Load text data from database by key (for example 'FOOTER_BLOCK'). To let me not to turn the models into a mess!
Give us forms where a SEO-person could paste the text
(Would be nice) Give us a WISIWIG editor.
PS: An example of such functionality (but not in Ruby): I used to code in python/Django. And we used django-flatblocks package - it did fit these 3 criterias.
I don't know any gem which will do this, but hopefully I can shed some light on how you might be able to achieve it
Code Blocks
You could create a table (and model) called code_blocks. The schema may look like this:
code_blocks
id | title | body | created_at | updated_at
This will allow you to create any number of records in this table that you want, and then call them from your app without the need for specific controller actions
Display
You could do this:
#app/helpers/application_helper.rb
def code_block(id)
block = CodeBlock.find(id)
return block.body
end
This may be inefficient, but it will allow you to include the code blocks whereever you want on the page, independent of the controller actions
So, for example, you have a footer block with id as 3, you could put:
<%= code_block(3) %>
Editing
This will mean that if you have a simple backend form, you can set it up so that you list the blocks by title, and allow the SEO guys to edit the HTML with a WYSIWYG editor (saving the HTML in the body column)
I am currently investigating the possibilities of different CMSs for a company-site. Done quite a few projects in classical ASP, ASP.NET, Joomla etc..
I would like to use Umbraco or Orchard for the first time.
For that project we have a SQL-Table with Departmenst and a second with Job-Opportunities: like: JobName, DepartmentID, Description, etc..
So a 1:n relationship.
A first page should list Departments with links to sub-pages of Jobs available
These should be listed on a second page.
In ASP.NET I would use something like a Repeater, etc.. with PageSize option and automatic paging.
In the Backend (Backoffice in Umbraco, I assume) there has to be an Insert/Edit/Delete Page with the corresponding input boxes, which are maintained by the company employees, not by web-developers.
So in both cms I try to accomplish an Access-like table-form in the backend like:
Job | Description | ....
Job1 | descr1 | ....[edit][delete]
Job2 | descr2 | ....[edit][delete]
Job3 | descr3 | ....[edit][delete]
[New Job]
Which route should I look at? I am completely stuck, is there an example anywhere? Can I use my own data-tables, or could/should I use the built-in content tables for this?
Thank you, Reinhard
This sounds relatively straightforward, in Umbraco anyway, you could use either the built-in content tables, or else use straight SQL server tables and write the code to 'talk' to the db yourself.
The benefit of using the content tables in Umbraco however, is that everything else will be easier to do; everything else in the system is designed to just use those content tables with no extra coding...unless you have a tremendous amount of data, or some special requirements you haven't mentioned, I would definitely fully explore the possibility of just using the built in Umbraco functionality for this, before deciding to roll-your-own custom tables within umbraco.
Its possible, and not that hard, but is is extra work that you shouldn't do unless necessary.
Not familiar with Orchard, so can't comment on that.
I've read the documentation, but what I need to know is:
I'm not using a fictitious stock quote service (with an imaginary wsdl file). I'm using a different service with a different name.
Where, among the thousands and thousands of lines of code that have been generated, will I find the Scala trait(s) that I need to put together that correspond to this line in the documentation's example:
val service = (new stockquote.StockQuoteSoap12Bindings with scalaxb.SoapClients with scalaxb.DispatchHttpClients {}).service
Now, you might be thinking "Why not just search for Soap12Bindings in the generated code"? Good idea - but that turns up 0 results.
The example in the documentation is outdated, or too specific. (The documentation is also internally inconsistent and inconsistent with the actual filenames output with scalaxb.)
First, search for SoapBindings instead of Soap12Bindings to find the service-specific trait (the first trait).
Then, instead of scalaxb.SoapClients, use scalaxb.Soap11Clients.
Ever wonder what wikipedia's database schema looks like? I recently read this thread from reddit.
I like how their tables are tagged with a prefix so you can sort of tell its functionality, purpose, and relationship with other tables right off the bat.
One thing I do not notice is how they name their stored procedures. Do they even use SP?
I use MS SQL Server. Prefixing all stored procedures with USP_ or SP_ seems redundant and anti-beneficial as the object explorer already sorts it all out for me. How do you name your SPs?
I like how their tables are tagged with a prefix so you can sort of tell its functionality, purpose, and relationship with other tables right off the bat
That is why you have Schemas in SQL Server, you create a schema to group several object together and then you can give the HR person just access to the HR schema
Prefixing all stored procedures with USP_ or SP_ seems redundant and anti-beneficial as the object explorer already sorts it all out for me. How do you name your SPs?
SP_ should never be use because you will get a performance hit, whenever SQL server 'sees' a proc that starts with sp_ it will check the master database first, worst if MS decided to ship a proc with the sane name as yours and it starts with sp_ yours will never get executed
BTW not everyone is using the project explorer, some people like to do this in T-SQL
I personally will prefix my stored procedures with a unique name the describes what it does. For example.
SelectUserAccountById
or
InsertUserAccount
Typically the table name is referenced in the name, in the example above, the table would be UserAccount.
I do not prefix my stored procedures with SP or anything similar UNLESS I am building an extension that goes into a framework such as DotNetNuke, then I use a prefix for my company name.
I find it useful to name the strored proc as
TableName_Action
example RefClient_Insert, RefClient_Search, RefEmployee_Delete
This way, since the tables are grouped (Ref = Reference in this case) the SPs are grouped too.
Note that I have used _ just for clarity, you may skip it if you like.
I started naming all of the SQL objects with a widget type prefix. For example...
Photo Gallery Database Objects (abbreviated list)
Old Name | New Name
-------------------------------------------------
tblCategories | tblPGCategories
tblItems | tblPGItems
spGetCategories | spPGGetCategories
spUpdateCategory | spPGUpdateCategory
spGetItems | spPGGetItems
spUpdateItem | spPGUpdateItems
Event Calendar Database Objects (abbreviated list)
Old Name | New Name
-------------------------------------------------
tblCategories | tblECCategories
tblItems | tblECItems
spGetCategories | spECGetCategories
spUpdateCategory | spECUpdateCategory
spGetItems | spECGetItems
spUpdateItem | spECUpdateItems
We developed lots of websites and when a customer wanted a piece of functionalty we thought we could sell to others we would create it as a widget. We would then market these widgets to other customers.
This worked great until we started adding widgets we developed from other websites. We wound up with duplicate names for some of our code. So, out of necessity we implement a widget type naming convention. This made it very easy to integrate all the widgets we created.