how to use sessions in my project to store project id and how to match sessions in code - ruby-on-rails-3

i want to store selected project's project_id in session and check it for the current user who are logged in... and match it in _shared.html.erb file.
how can i write condition in _shared file and how can i match them in controller??\
i am selecting project from dropdown list.
Jquery is needed to do... i got id of selected project in dropdown list but not able to list activity...
#project = Project.find(params[:id])
session[:project_id] = #project.id
is this works to store session?
i want to list all activity acording to project select from dropdown list and make session until i select next project.
all activity should change for the project to my dashboard. and same for other links that also works for it.
if you have any best and understandable ajax video or tutorial link then pls suggest to me....
thanks in advance.. :)

This is the way u can store in sessions.
#project = Project.find(params[:id])
session[:project_id] = #project.id
you are going in right direction. and access this session using
session[:project_id]
where u needed.

Related

How can we make an Item in socialengine?

I know how to get an item of the particular table. Like for user we can have
$userItem = Engine_Api::_()->getItem("user", $userId);
or for a custom table
$customItem = Engine_Api::_()->getItem("custom", $customeId);
I want to know the code or method how can I make my $customItem to work the same way as $userItem works for users table. So that I can get data or manipulate the data of custom table
Thanks for your help. :-)
You can achieve that by creating a model. Check how it's done in /application/modules/User/Model. There is User.php file that declares User_Model_User and methods available for User such as getTitle, get Href etc.
You may use similar approach for your custom item. You will also need to create a file similar to /application/modules/User/Model/DbTable/User.php to declare table for your custom items.

How to display only selected products in Spree?

Am using Spree Commerce, and right now every product I add on my backend is displayed on the homepage. Is there a way that I can display only products of my choice on the frontpage, and not display everything as it does by default?
I know deface allows me to customise the look of everything, but it is not the answer I am looking for.
Thanks
#elliot Actually it's pretty simple. Go to product's edit page on admin end and set discontinue_on for that product with a date equal to the current date or lesser.
Only those product are visible on the frontend for which available_on is lesser than the current date and discontinue_on is greater than the current date.
Deface is used to changing views not a controllers. A fetching products from DB is a controller logic.
There is a lot of options, you can add your own scopes in product model and override controller to use them, but fastest is use discontinue_on because for not admin user spree uses usually active scope on products.
Found the answer: I just changed #products = #searcher.retrieve_products to #products = Product.joins(:variants_including_master).where(:name => "Ruby on Rails Tote").uniq on my index action in home_controller_decorator.rb

Adding quick link on admin home page (Prestashop 1.5.4)

Good day! Tell me, how can I add a quick link on the home page of the administrator to configure my module?
Follow the following steps:
1) In admin section to go Administration at top menu and then click on Quick Access.
2) IN next page click on Add new and you will see a form
3) Now open admin panel in another tab and to the module page or section, of which you want to place a link in quick access.
4) Copy that complete link in note pad and remove the token section of the link. It is required to remove the token section according to Prestashop.
5) Now come back to the add new form for quick access, give your link a name and then copy that modified link to the Url field.
6) Save it and you will have that link in quick access.
The above is method is used to add it at admin. Now if you want to add it pro-grammatically you can follow the following steps.
1) In your module in the install function, user a code like below
Db::getInstance()->insert('quick_access', array('new_window' => 0, 'link' => 'link_to_your_module_page'));
//an entry is made in quick_access table, get the quick_access id to insert lang data
$id = Db::getInstance()->Insert_ID(); //this will give you last inserted ID from quick_access table which is your current quick_access id.
//now make insertions in quick_access_lang table for multi language data.
//get all your site languages, and place a foreach loop and in that loop insert
//data into the quick_access_lang table using below code
Db::getInstance()->insert('quick_access_lang', array('id_quick_access' => $id, 'id_lang' => 'lang_id', 'name' => 'name of your link'));
//Now for uninstalling module, you want to delete the link, so you need to store the quick access link id in configuration table so you can use it later.
Configuration::updateValue('MY_QUICK_ACCESS_LINK_ID', $id);
2) Now in your uninstall function in your module class, place the below code
$id = Configuration::get('MY_QUICK_ACCESS_LINK_ID'); //get id of your quick access link
Db::getInstance()->delete('quick_access', 'where id_quick_access = '.$id);
Db::getInstance()->delete('quick_access_lang', 'where id_quick_access = '.$id);
//now delete the id from config table
Configuration::deleteByName('MY_QUICK_ACCESS_LINK_ID');
Note : The above code is not tested, it may / may not need some adjustments.
Thank you
There is a hook in Prestashop DisplayAdminHomeQuickLinks it will help you to add quick link on prestashop admin panel. I have use this in my theme. http://goo.gl/0S3mn And it will help you to solve the quick link.
In Prestashop 1.6.1 (maybe earlier too) in Admin view, at the top of the page, Quick Access has the option to "Add current page to QuickAccess". So just navigate to the Configuration page you need and use it.

What are the Aweber API Variables $account_id and $list_id?

You can check here:
https://labs.aweber.com/docs/code_samples/subs/create
The script to add a new subscriber to the list via api requires those two pieces info...only I cannot figure out for the life of me what those two variables are!! I've beaten through every little aspect of my Aweber Subscriber Account, AND my Aweber Labs account...and I can't find any reference to either of those variables anywhere. I've submitted some tickets to them, and haven't gotten any response yet.
Does anyone have any ideas here? I've tried my account names, my list names, to no avail!
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Okay, I've got it! You can get the values of both of these variables by dumping some other variables in the aweber api after making certain api calls.
get the account id first:
$account = $aweber->getAccount($accessKey, $accessSecret);
then vardump or print_r $account.
next we get the list id:
$account = $aweber->getAccount($accessKey, $accessSecret);
$list_url = 'https://api.aweber.com/1.0/accounts/<id>/lists';
$lists = $account->loadFromUrl($list_url);
then vardump or print_r $lists.
And you are all set! I'm so happy I figured this out, it freakin took long enough. Hopefully this saves some one a bit of time.
I too have agonized over finding the $list_ID, so went to deactivate the list, and create a new one, and "discovered" that if you hover over the Deactivate button, you get a url you can copy, and this gives both %account and %list Ids
https://www.aweber.com/users/lists/deactivate/$accountID/$lisID
like this....
https://www.aweber.com/users/lists/deactivate/123456/123456
Hopefully this will help make someone as it is a super easy solution
The proper answer is Anne Allen's one, but...
Check the return of the /accounts endpoint. It should return the same account id as you detected in the link, but I had cases they were different (strange, isn't it?). Use the account id returned by the /accounts endpoint and other endpoints to retrieve lists, subscribers, etc. will start to work. It's like if some accounts have two ids, one partially works and the other fully works.
Let me tell you how to get $list_id value... login into your AWeber account and then create a new list copy only integer value from list's name.
At first, login.
1) click Reports>Settings. Your account ID will be displayed in the box,example: ?id=XXXXX
2) click List Options>List Settings. There you will see the list ID under the name.
p.s. To add subscriber, you can use this - Automatically add into aweber list

How to get work items associated with a changeset id using tfs api?

Hi I need to get a list of work items that are associated with selected changesets programmatically. So far I have been able to get the changesets associated with a work item ID using the concept of Artifacts, as well as got the changesets and/or workitems associated with a particular build using :
InformationNodeConverters.GetAssociatedChangesets() and InformationNodeConverters.GetAssociatedWorkItems() respectively.
I am using VSTS 2010 beta 1. Anyone know the solution?
Try this:
Changeset cs = versionControlServer.GetChangeset(changesetId);
foreach (WorkItem wi in cs.WorkItems)
{
Console.WriteLine(wi.ID);
}